finishing sqlite changes
- finished default/active server logic - dev done - needs testing
This commit is contained in:
@@ -4,7 +4,10 @@ Copyright © 2025 Jake jake.young.dev@gmail.com
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"code.jakeyoungdev.com/jake/mctl/database"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -12,18 +15,27 @@ import (
|
||||
|
||||
// destroyCmd represents the destroy command
|
||||
var destroyCmd = &cobra.Command{
|
||||
Use: "destroy",
|
||||
// Short: "Clear all configuration",
|
||||
// Long: `Clears all configuration values for mctl. [WARNING] all server configuration will be lost`,
|
||||
Use: "destroy",
|
||||
Short: "clears all configuration",
|
||||
Long: `clear all data and drop database tables, this will delete all previously saved data and the 'inti' command
|
||||
must be run again before use`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
db, err := database.New()
|
||||
cobra.CheckErr(err)
|
||||
defer db.Close()
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
fmt.Printf("Are you sure you want to destroy your config? (yes|no): ")
|
||||
if scanner.Scan() {
|
||||
if strings.EqualFold(scanner.Text(), "yes") {
|
||||
db, err := database.New()
|
||||
cobra.CheckErr(err)
|
||||
defer db.Close()
|
||||
|
||||
err = db.Destroy()
|
||||
cobra.CheckErr(err)
|
||||
err = db.Destroy()
|
||||
cobra.CheckErr(err)
|
||||
|
||||
fmt.Println("Configuration is cleared, the 'init' command must be run again.")
|
||||
fmt.Println("Configuration is cleared, the 'init' command must be run again.")
|
||||
}
|
||||
} else {
|
||||
return
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user