package cmd import ( "fmt" "git.wntrmute.dev/kyle/arca/internal/config" "github.com/spf13/cobra" ) var removeCmd = &cobra.Command{ Use: "remove ", Short: "Remove a device from the config", Args: cobra.ExactArgs(1), RunE: runRemove, ValidArgsFunction: completeDeviceOrAlias, } func init() { rootCmd.AddCommand(removeCmd) } func runRemove(cmd *cobra.Command, args []string) error { alias := args[0] cfg := config.Load() if _, ok := cfg.Devices[alias]; !ok { return fmt.Errorf("no device with alias %q in config", alias) } delete(cfg.Devices, alias) if err := cfg.Save(); err != nil { return fmt.Errorf("saving config: %w", err) } fmt.Printf("Removed %q from config\n", alias) return nil }