package cmd import ( "fmt" "log" "github.com/Jaculabilis/intake/core" _ "github.com/mattn/go-sqlite3" "github.com/spf13/cobra" ) var itemDeactivateCmd = &cobra.Command{ Use: "deactivate", Aliases: []string{"deac"}, Short: "Deactivate an item", Long: `Deactivate items, hiding them from feeds and marking them for deletion. Deactivation is idempotent.`, Run: func(cmd *cobra.Command, args []string) { itemDeactivate(stringArg(cmd, "source"), stringArg(cmd, "item")) }, } func init() { itemCmd.AddCommand(itemDeactivateCmd) itemDeactivateCmd.Flags().StringP("source", "s", "", "Source of the item") itemDeactivateCmd.MarkFlagRequired("source") itemDeactivateCmd.Flags().StringP("item", "i", "", "Item id") itemDeactivateCmd.MarkFlagRequired("item") } func itemDeactivate(source string, item string) { db := openAndMigrateDb() active, err := core.DeactivateItem(db, source, item) if err != nil { log.Fatalf("Failed to deactivate item: %s", err) } if active { fmt.Printf("Deactivated %s/%s\n", source, item) } }