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() }, } var deacSource string var deacItem string func init() { itemCmd.AddCommand(itemDeactivateCmd) itemDeactivateCmd.Flags().StringVarP(&deacSource, "source", "s", "", "Source of the item") itemDeactivateCmd.MarkFlagRequired("source") itemDeactivateCmd.Flags().StringVarP(&deacItem, "item", "i", "", "Item id") itemDeactivateCmd.MarkFlagRequired("item") } func itemDeactivate() { db, err := core.OpenDb(getDbPath()) if err != nil { log.Fatalf("Failed to open %s", dbPath) } core.InitDatabase(db) core.MigrateDatabase(db) active, err := core.DeactivateItem(db, deacSource, deacItem) if err != nil { log.Fatalf("Failed to deactivate item: %s", err) } if active { fmt.Printf("Deactivated %s/%s\n", deacSource, deacItem) } }