- added 'command' subcommand - removed viper - setup commands added - still a WIP - readme TODO update
40 lines
751 B
Go
40 lines
751 B
Go
/*
|
|
Copyright © 2025 Jake jake.young.dev@gmail.com
|
|
*/
|
|
package command
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"code.jakeyoungdev.com/jake/mctl/database"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var deleteCmd = &cobra.Command{
|
|
Use: "delete",
|
|
Example: "mctl command delete <name>",
|
|
// Short: "Deletes a server",
|
|
// Long: `Deletes server configuration`,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
db, err := database.New()
|
|
cobra.CheckErr(err)
|
|
defer db.Close()
|
|
|
|
err = db.DeleteCmd(args[0])
|
|
cobra.CheckErr(err)
|
|
|
|
fmt.Println("Command deleted!")
|
|
},
|
|
PreRunE: func(cmd *cobra.Command, args []string) error {
|
|
if len(args) == 0 {
|
|
return errors.New("name parameter missing")
|
|
}
|
|
return nil
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
CommandCmd.AddCommand(deleteCmd)
|
|
}
|