[fix] Testing fixes
- sqlite error handling and wrapping - more responsive commands - database updates
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"code.jakeyoungdev.com/jake/mctl/cmd/command"
|
||||
"code.jakeyoungdev.com/jake/mctl/database"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@@ -19,6 +20,7 @@ var destroyCmd = &cobra.Command{
|
||||
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`,
|
||||
SilenceUsage: true,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
fmt.Printf("Are you sure you want to destroy your config? (yes|no): ")
|
||||
@@ -29,6 +31,10 @@ var destroyCmd = &cobra.Command{
|
||||
defer db.Close()
|
||||
|
||||
err = db.Destroy()
|
||||
if err.Error() == command.ErrInit {
|
||||
fmt.Println(command.ErrInitRsp)
|
||||
return
|
||||
}
|
||||
cobra.CheckErr(err)
|
||||
|
||||
fmt.Println("Configuration is cleared, the 'init' command must be run again.")
|
||||
|
||||
Reference in New Issue
Block a user