diff --git a/cmd/action.go b/cmd/action.go new file mode 100644 index 0000000..14db3a7 --- /dev/null +++ b/cmd/action.go @@ -0,0 +1,16 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +var actionCmd = &cobra.Command{ + Use: "action", + Short: "Manage and run source actions", + Long: ` +`, +} + +func init() { + rootCmd.AddCommand(actionCmd) +} diff --git a/cmd/actionAdd.go b/cmd/actionAdd.go new file mode 100644 index 0000000..ec27c96 --- /dev/null +++ b/cmd/actionAdd.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" +) + +var actionAddCmd = &cobra.Command{ + Use: "add", + Short: "Add an action to a source", + Long: ` +`, + Run: func(cmd *cobra.Command, args []string) { + log.Fatal("not implemented") + }, +} + +func init() { + actionCmd.AddCommand(actionAddCmd) +} diff --git a/cmd/actionDelete.go b/cmd/actionDelete.go new file mode 100644 index 0000000..d033a3b --- /dev/null +++ b/cmd/actionDelete.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" +) + +var actionDeleteCmd = &cobra.Command{ + Use: "delete", + Short: "Delete an action from a source", + Long: ` +`, + Run: func(cmd *cobra.Command, args []string) { + log.Fatal("not implemented") + }, +} + +func init() { + actionCmd.AddCommand(actionDeleteCmd) +} diff --git a/cmd/actionEdit.go b/cmd/actionEdit.go new file mode 100644 index 0000000..03ed1f5 --- /dev/null +++ b/cmd/actionEdit.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" +) + +var actionEditCmd = &cobra.Command{ + Use: "edit", + Short: "Edit an action", + Long: ` +`, + Run: func(cmd *cobra.Command, args []string) { + log.Fatal("not implemented") + }, +} + +func init() { + actionCmd.AddCommand(actionEditCmd) +} diff --git a/cmd/actionExecute.go b/cmd/actionExecute.go new file mode 100644 index 0000000..2ea29a2 --- /dev/null +++ b/cmd/actionExecute.go @@ -0,0 +1,22 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" +) + +var actionExecuteCmd = &cobra.Command{ + Use: "execute", + Aliases: []string{"exec"}, + Short: "Run a source action for an item", + Long: ` +`, + Run: func(cmd *cobra.Command, args []string) { + log.Fatal("not implemented") + }, +} + +func init() { + actionCmd.AddCommand(actionExecuteCmd) +} diff --git a/cmd/channel.go b/cmd/channel.go new file mode 100644 index 0000000..2557149 --- /dev/null +++ b/cmd/channel.go @@ -0,0 +1,16 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +var channelCmd = &cobra.Command{ + Use: "channel", + Short: "Manage channels", + Long: ` +`, +} + +func init() { + rootCmd.AddCommand(channelCmd) +} diff --git a/cmd/channelAdd.go b/cmd/channelAdd.go new file mode 100644 index 0000000..5d3ee18 --- /dev/null +++ b/cmd/channelAdd.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" +) + +var channelAddCmd = &cobra.Command{ + Use: "add", + Short: "Create a channel", + Long: ` +`, + Run: func(cmd *cobra.Command, args []string) { + log.Fatal("not implemented") + }, +} + +func init() { + channelCmd.AddCommand(channelAddCmd) +} diff --git a/cmd/channelDelete.go b/cmd/channelDelete.go new file mode 100644 index 0000000..f2a21bb --- /dev/null +++ b/cmd/channelDelete.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" +) + +var channelDeleteCmd = &cobra.Command{ + Use: "delete", + Short: "Delete a channel", + Long: ` +`, + Run: func(cmd *cobra.Command, args []string) { + log.Fatal("not implemented") + }, +} + +func init() { + channelCmd.AddCommand(channelDeleteCmd) +} diff --git a/cmd/channelEdit.go b/cmd/channelEdit.go new file mode 100644 index 0000000..40a7080 --- /dev/null +++ b/cmd/channelEdit.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" +) + +var channelEditCmd = &cobra.Command{ + Use: "edit", + Short: "Edit a channel", + Long: ` +`, + Run: func(cmd *cobra.Command, args []string) { + log.Fatal("not implemented") + }, +} + +func init() { + channelCmd.AddCommand(channelEditCmd) +} diff --git a/cmd/feed.go b/cmd/feed.go index 0260036..fc21f88 100644 --- a/cmd/feed.go +++ b/cmd/feed.go @@ -10,7 +10,7 @@ import ( var feedCmd = &cobra.Command{ Use: "feed", - Short: "Print item feeds", + Short: "Display the item feed", Long: `Display the intake item feed in various formats. The default format is "headlines". diff --git a/cmd/item.go b/cmd/item.go new file mode 100644 index 0000000..a498759 --- /dev/null +++ b/cmd/item.go @@ -0,0 +1,16 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +var itemCmd = &cobra.Command{ + Use: "item", + Short: "Manage items", + Long: `Add, edit, or deactivate items. +`, +} + +func init() { + rootCmd.AddCommand(itemCmd) +} diff --git a/cmd/add.go b/cmd/itemAdd.go similarity index 64% rename from cmd/add.go rename to cmd/itemAdd.go index 597aa3c..15c6746 100644 --- a/cmd/add.go +++ b/cmd/itemAdd.go @@ -11,7 +11,7 @@ import ( "github.com/spf13/cobra" ) -var addCmd = &cobra.Command{ +var itemAddCmd = &cobra.Command{ Use: "add", Short: "Add an item", Long: `Create an ad-hoc item in a source. @@ -19,7 +19,7 @@ var addCmd = &cobra.Command{ By default, the item is created in the "default" source, which is created if it doesn't exist, with a random id.`, Run: func(cmd *cobra.Command, args []string) { - add() + itemAdd() }, } @@ -32,18 +32,18 @@ var addLink string var addTime int func init() { - rootCmd.AddCommand(addCmd) + itemCmd.AddCommand(itemAddCmd) - addCmd.Flags().StringVarP(&addSource, "source", "s", "", "Source in which to create the item (default: default)") - addCmd.Flags().StringVarP(&addId, "item", "i", "", "Item id (default: random hex)") - addCmd.Flags().StringVarP(&addTitle, "title", "t", "", "Item title") - addCmd.Flags().StringVarP(&addAuthor, "author", "a", "", "Item author") - addCmd.Flags().StringVarP(&addBody, "body", "b", "", "Item body") - addCmd.Flags().StringVarP(&addLink, "link", "l", "", "Item link") - addCmd.Flags().IntVarP(&addTime, "time", "m", 0, "Item time as a Unix timestamp") + itemAddCmd.Flags().StringVarP(&addSource, "source", "s", "", "Source in which to create the item (default: default)") + itemAddCmd.Flags().StringVarP(&addId, "item", "i", "", "Item id (default: random hex)") + itemAddCmd.Flags().StringVarP(&addTitle, "title", "t", "", "Item title") + itemAddCmd.Flags().StringVarP(&addAuthor, "author", "a", "", "Item author") + itemAddCmd.Flags().StringVarP(&addBody, "body", "b", "", "Item body") + itemAddCmd.Flags().StringVarP(&addLink, "link", "l", "", "Item link") + itemAddCmd.Flags().IntVarP(&addTime, "time", "m", 0, "Item time as a Unix timestamp") } -func add() { +func itemAdd() { // Default to "default" source if addSource == "" { addSource = "default" diff --git a/cmd/deactivate.go b/cmd/itemDeactivate.go similarity index 65% rename from cmd/deactivate.go rename to cmd/itemDeactivate.go index bd5a233..9aab315 100644 --- a/cmd/deactivate.go +++ b/cmd/itemDeactivate.go @@ -9,15 +9,15 @@ import ( "github.com/spf13/cobra" ) -var deactivateCmd = &cobra.Command{ +var itemDeactivateCmd = &cobra.Command{ Use: "deactivate", Aliases: []string{"deac"}, - Short: "Deactivate items", + 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) { - deactivate() + itemDeactivate() }, } @@ -25,15 +25,15 @@ var deacSource string var deacItem string func init() { - rootCmd.AddCommand(deactivateCmd) + itemCmd.AddCommand(itemDeactivateCmd) - deactivateCmd.Flags().StringVarP(&deacSource, "source", "s", "", "Source of the item") - deactivateCmd.MarkFlagRequired("source") - deactivateCmd.Flags().StringVarP(&deacItem, "item", "i", "", "Item id") - deactivateCmd.MarkFlagRequired("item") + 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 deactivate() { +func itemDeactivate() { db, err := core.OpenDb(getDbPath()) if err != nil { log.Fatalf("Failed to open %s", dbPath) diff --git a/cmd/itemEdit.go b/cmd/itemEdit.go new file mode 100644 index 0000000..66ae034 --- /dev/null +++ b/cmd/itemEdit.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" +) + +var itemEditCmd = &cobra.Command{ + Use: "edit", + Short: "Edit an item", + Long: ` +`, + Run: func(cmd *cobra.Command, args []string) { + log.Fatal("not implemented") + }, +} + +func init() { + itemCmd.AddCommand(itemEditCmd) +} diff --git a/cmd/passwd.go b/cmd/passwd.go new file mode 100644 index 0000000..7166d9c --- /dev/null +++ b/cmd/passwd.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" +) + +var passwdCmd = &cobra.Command{ + Use: "passwd", + Short: "Set the password for the web interface", + Long: ` +`, + Run: func(cmd *cobra.Command, args []string) { + log.Fatal("not implemented") + }, +} + +func init() { + rootCmd.AddCommand(passwdCmd) +} diff --git a/cmd/serve.go b/cmd/serve.go new file mode 100644 index 0000000..812747e --- /dev/null +++ b/cmd/serve.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" +) + +var serveCmd = &cobra.Command{ + Use: "serve", + Short: "Serve the web interface", + Long: ` +`, + Run: func(cmd *cobra.Command, args []string) { + log.Fatal("not implemented") + }, +} + +func init() { + rootCmd.AddCommand(serveCmd) +} diff --git a/cmd/source.go b/cmd/source.go new file mode 100644 index 0000000..fe8d90e --- /dev/null +++ b/cmd/source.go @@ -0,0 +1,19 @@ +/* +Copyright © 2025 NAME HERE +*/ +package cmd + +import ( + "github.com/spf13/cobra" +) + +var sourceCmd = &cobra.Command{ + Use: "source", + Short: "Manage sources", + Long: ` +`, +} + +func init() { + rootCmd.AddCommand(sourceCmd) +} diff --git a/cmd/sourceAdd.go b/cmd/sourceAdd.go new file mode 100644 index 0000000..6682e13 --- /dev/null +++ b/cmd/sourceAdd.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" +) + +var sourceAddCmd = &cobra.Command{ + Use: "add", + Short: "Create a source", + Long: ` +`, + Run: func(cmd *cobra.Command, args []string) { + log.Fatal("not implemented") + }, +} + +func init() { + sourceCmd.AddCommand(sourceAddCmd) +} diff --git a/cmd/sourceDeactivate.go b/cmd/sourceDeactivate.go new file mode 100644 index 0000000..858e615 --- /dev/null +++ b/cmd/sourceDeactivate.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" +) + +var sourceDeactivateCmd = &cobra.Command{ + Use: "deactivate", + Short: "Deactivate all items in a source", + Long: ` +`, + Run: func(cmd *cobra.Command, args []string) { + log.Fatal("not implemented") + }, +} + +func init() { + sourceCmd.AddCommand(sourceDeactivateCmd) +} diff --git a/cmd/sourceDelete.go b/cmd/sourceDelete.go new file mode 100644 index 0000000..7beb572 --- /dev/null +++ b/cmd/sourceDelete.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" +) + +var sourceDeleteCmd = &cobra.Command{ + Use: "delete", + Short: "Delete a source", + Long: ` +`, + Run: func(cmd *cobra.Command, args []string) { + log.Fatal("not implemented") + }, +} + +func init() { + sourceCmd.AddCommand(sourceDeleteCmd) +} diff --git a/cmd/sourceEdit.go b/cmd/sourceEdit.go new file mode 100644 index 0000000..8b80ae0 --- /dev/null +++ b/cmd/sourceEdit.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" +) + +var sourceEditCmd = &cobra.Command{ + Use: "edit", + Short: "Edit a source", + Long: ` +`, + Run: func(cmd *cobra.Command, args []string) { + log.Fatal("not implemented") + }, +} + +func init() { + sourceCmd.AddCommand(sourceEditCmd) +} diff --git a/cmd/update.go b/cmd/sourceFetch.go similarity index 62% rename from cmd/update.go rename to cmd/sourceFetch.go index 6232e2b..eb8de2b 100644 --- a/cmd/update.go +++ b/cmd/sourceFetch.go @@ -9,14 +9,16 @@ import ( "github.com/spf13/cobra" ) -var updateCmd = &cobra.Command{ - Use: "update", - Short: "Fetch items for a source and update it", +var sourceFetchCmd = &cobra.Command{ + Use: "fetch", + Short: "Fetch items for a source and update the feed", Long: `Fetch items from a feed source using the configured "fetch" action. Items returned by a successful fetch will be used to update the source. -No changes will be made to the source if the fetch does not succeed.`, +A fetch is successful if all items output by the fetch are parsed successfully +and the exit code is 0. No changes will be made to the source if the fetch +does not succeed.`, Run: func(cmd *cobra.Command, args []string) { - update() + sourceFetch() }, } @@ -24,15 +26,15 @@ var source string var dryRun bool func init() { - rootCmd.AddCommand(updateCmd) + sourceCmd.AddCommand(sourceFetchCmd) - updateCmd.Flags().StringVarP(&source, "source", "s", "", "Source name to fetch (required)") - updateCmd.MarkFlagRequired("source") + sourceFetchCmd.Flags().StringVarP(&source, "source", "s", "", "Source name to fetch (required)") + sourceFetchCmd.MarkFlagRequired("source") - updateCmd.Flags().BoolVar(&dryRun, "dry-run", false, "Instead of updating the source, print the fetched items") + sourceFetchCmd.Flags().BoolVar(&dryRun, "dry-run", false, "Instead of updating the source, print the fetched items") } -func update() { +func sourceFetch() { fmt.Printf("Hello %s\n", source) if dryRun { diff --git a/cmd/test.go b/cmd/sourceTest.go similarity index 62% rename from cmd/test.go rename to cmd/sourceTest.go index 2ada763..e5edd7b 100644 --- a/cmd/test.go +++ b/cmd/sourceTest.go @@ -9,18 +9,18 @@ import ( "github.com/spf13/cobra" ) -var testCmd = &cobra.Command{ - Use: "test [flags] -- command", - Short: "Test a feed source", +var sourceTestCmd = &cobra.Command{ + Use: "test [flags] -- argv", + Short: "Test a fetch action", Long: `Execute a command as if it were a feed source's fetch action. The display format of the returned items is the same as "intake feed".`, Run: func(cmd *cobra.Command, args []string) { l := cmd.Flags().ArgsLenAtDash() if l == -1 { - test(nil) + sourceTest(nil) } else { - test(args[l:]) + sourceTest(args[l:]) } }, } @@ -29,13 +29,13 @@ var testEnv []string var testFormat string func init() { - rootCmd.AddCommand(testCmd) + sourceCmd.AddCommand(sourceTestCmd) - testCmd.Flags().StringArrayVarP(&testEnv, "env", "e", nil, "Environment variables to set, in the form KEY=VAL") - testCmd.Flags().StringVarP(&testFormat, "format", "f", "headlines", "Feed format for returned items.") + sourceTestCmd.Flags().StringArrayVarP(&testEnv, "env", "e", nil, "Environment variables to set, in the form KEY=VAL") + sourceTestCmd.Flags().StringVarP(&testFormat, "format", "f", "headlines", "Feed format for returned items.") } -func test(cmd []string) { +func sourceTest(cmd []string) { formatter, err := core.FormatAs(testFormat) if err != nil { log.Fatal(err)