/* Copyright © 2025 Jake jake.young.dev@gmail.com */ package cmd import ( "errors" "github.com/spf13/cobra" "github.com/spf13/viper" ) // deleteCmd represents the delete command var deleteCmd = &cobra.Command{ Use: "delete ", Example: "mctl delete newcmd", Short: "Delete a saved command", Long: `Deletes a command stored using the save command`, Run: func(cmd *cobra.Command, args []string) { if viper.IsSet("customcmd") { cmdMap := viper.Get("customcmd").(map[string]any) delete(cmdMap, args[0]) viper.Set("customcmd", cmdMap) viper.WriteConfig() } }, PreRunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { return errors.New("name argument is required") } return nil }, } func init() { rootCmd.AddCommand(deleteCmd) }