package cmd import ( "log" "github.com/Jaculabilis/intake/core" "github.com/spf13/cobra" ) var actionDeleteCmd = &cobra.Command{ Use: "delete", Aliases: []string{"rm"}, Short: "Delete an action from a source", Long: `Delete an action from a source. `, Run: func(cmd *cobra.Command, args []string) { actionDelete() }, } var actionDeleteSource string var actionDeleteAction string func init() { actionCmd.AddCommand(actionDeleteCmd) actionDeleteCmd.Flags().StringVarP(&actionDeleteSource, "source", "s", "", "Source to add action") actionDeleteCmd.MarkFlagRequired("source") actionDeleteCmd.Flags().StringVarP(&actionDeleteAction, "action", "a", "", "Action name") actionDeleteCmd.MarkFlagRequired("action") } func actionDelete() { if actionDeleteSource == "" { log.Fatal("error: --source is empty") } if actionDeleteAction == "" { log.Fatal("error: --action is empty") } db := openAndMigrateDb() err := core.DeleteAction(db, actionDeleteSource, actionDeleteAction) if err != nil { log.Fatalf("error: %v", err) } log.Printf("Deleted action %s from source %s", actionDeleteAction, actionDeleteSource) }