Add command groups

This commit is contained in:
Tim Van Baak 2025-03-07 10:06:28 -08:00
parent fabd5110c3
commit 92ce484dea
14 changed files with 43 additions and 22 deletions

View File

@ -5,8 +5,9 @@ import (
) )
var actionCmd = &cobra.Command{ var actionCmd = &cobra.Command{
Use: "action", Use: "action",
Short: "Manage and run source actions", GroupID: sourceGroup.ID,
Short: "Manage and run source actions",
Long: `Add, edit, delete, and run source actions on items. Long: `Add, edit, delete, and run source actions on items.
A feed source is updated by the "fetch" action, which receives no input and A feed source is updated by the "fetch" action, which receives no input and

View File

@ -10,8 +10,9 @@ import (
) )
var channelCmd = &cobra.Command{ var channelCmd = &cobra.Command{
Use: "channel --channel name {--add source | --remove source | --delete [-y]}", Use: "channel --channel name {--add source | --remove source | --delete [-y]}",
Short: "Manage channels", GroupID: sourceGroup.ID,
Short: "Manage channels",
Long: `A channel is a group of sources that can be viewed together. Adding a source Long: `A channel is a group of sources that can be viewed together. Adding a source
to a channel creates it and removing all sources from a channel deletes it. to a channel creates it and removing all sources from a channel deletes it.
`, `,

View File

@ -12,6 +12,7 @@ import (
var deactivateCmd = &cobra.Command{ var deactivateCmd = &cobra.Command{
Use: "deactivate --source source [--item item]", Use: "deactivate --source source [--item item]",
GroupID: feedGroup.ID,
Aliases: []string{"deac"}, Aliases: []string{"deac"},
Short: "Deactivate items", Short: "Deactivate items",
Long: `Deactivate items, hiding them from feeds and marking them for deletion. Long: `Deactivate items, hiding them from feeds and marking them for deletion.

View File

@ -7,8 +7,9 @@ import (
) )
var editCmd = &cobra.Command{ var editCmd = &cobra.Command{
Use: "edit", Use: "edit",
Short: "Edit an item", GroupID: feedGroup.ID,
Short: "Edit an item",
Long: ` Long: `
`, `,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {

View File

@ -8,8 +8,9 @@ import (
) )
var envCmd = &cobra.Command{ var envCmd = &cobra.Command{
Use: "env", Use: "env",
Short: "Manage source environment variables", GroupID: sourceGroup.ID,
Short: "Manage source environment variables",
Long: `Add, edit, list, or delete environment variables. Long: `Add, edit, list, or delete environment variables.
--env KEY=VALUE will add or edit an environment variable to be set in all --env KEY=VALUE will add or edit an environment variable to be set in all

View File

@ -9,8 +9,9 @@ import (
) )
var feedCmd = &cobra.Command{ var feedCmd = &cobra.Command{
Use: "feed", Use: "feed",
Short: "Display the item feed", GroupID: feedGroup.ID,
Short: "Display the item feed",
Long: fmt.Sprintf(`Display the intake item feed in various formats. Long: fmt.Sprintf(`Display the intake item feed in various formats.
The default format is "headlines". The default format is "headlines".

View File

@ -11,8 +11,9 @@ import (
) )
var fetchCmd = &cobra.Command{ var fetchCmd = &cobra.Command{
Use: "fetch [--source name] [-n|--dry-run] [--env NAME-VALUE [-- env NAME=VALUE ...]] [-- argv...]", Use: "fetch [--source name] [-n|--dry-run] [--env NAME-VALUE [-- env NAME=VALUE ...]] [-- argv...]",
Short: "Fetch items for a source and update the feed", GroupID: feedGroup.ID,
Short: "Fetch items for a source and update the feed",
Long: fmt.Sprintf(`Fetch items for a source and update the feed. Long: fmt.Sprintf(`Fetch items for a source and update the feed.
Items returned by a successful fetch will be used to update the source. Items returned by a successful fetch will be used to update the source.

View File

@ -10,8 +10,9 @@ import (
) )
var itemCmd = &cobra.Command{ var itemCmd = &cobra.Command{
Use: "item", Use: "item",
Short: "Add an item", GroupID: feedGroup.ID,
Short: "Add an item",
Long: `Create an ad-hoc item in a source. Long: `Create an ad-hoc item in a source.
By default, the item is created in the "default" source, which is created By default, the item is created in the "default" source, which is created

View File

@ -12,6 +12,7 @@ import (
var listCmd = &cobra.Command{ var listCmd = &cobra.Command{
Use: "list", Use: "list",
GroupID: sourceGroup.ID,
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Short: "List sources, channels, or actions", Short: "List sources, channels, or actions",
Long: `List sources, channels, or actions. Long: `List sources, channels, or actions.

View File

@ -9,8 +9,9 @@ import (
) )
var monitorCmd = &cobra.Command{ var monitorCmd = &cobra.Command{
Use: "monitor", Use: "monitor",
Short: "Run continuously and update sources according to their fetch schedule", GroupID: webGroup.ID,
Short: "Run continuously and update sources according to their fetch schedule",
Long: `Run continuously and update sources. Long: `Run continuously and update sources.
Sources are monitored and fetched according to the schedule specified by Sources are monitored and fetched according to the schedule specified by

View File

@ -11,8 +11,9 @@ import (
) )
var passwdCmd = &cobra.Command{ var passwdCmd = &cobra.Command{
Use: "passwd", Use: "passwd",
Short: "Set the password for the web interface", GroupID: webGroup.ID,
Short: "Set the password for the web interface",
Long: `Set the password for the web interface. Long: `Set the password for the web interface.
Access through the command line should be controlled by standard filesystem Access through the command line should be controlled by standard filesystem

View File

@ -25,10 +25,18 @@ func Execute() {
var dataPath string var dataPath string
var sourceGroup = &cobra.Group{ID: "manage", Title: "Source management:"}
var feedGroup = &cobra.Group{ID: "feed", Title: "Feed management:"}
var webGroup = &cobra.Group{ID: "web", Title: "Service management:"}
func init() { func init() {
// Disable the automatic help command // Disable the automatic help command
rootCmd.SetHelpCommand(&cobra.Command{Hidden: true}) rootCmd.SetHelpCommand(&cobra.Command{Hidden: true})
rootCmd.AddGroup(sourceGroup)
rootCmd.AddGroup(feedGroup)
rootCmd.AddGroup(webGroup)
// All commands need to operate on a database // All commands need to operate on a database
// Setting the env-derived path as the default allows the command line to override the env // Setting the env-derived path as the default allows the command line to override the env
dbPathFromEnv := core.ResolveEnvDataDir() dbPathFromEnv := core.ResolveEnvDataDir()

View File

@ -11,8 +11,9 @@ import (
) )
var serveCmd = &cobra.Command{ var serveCmd = &cobra.Command{
Use: "serve", Use: "serve",
Short: "Serve the web interface", GroupID: webGroup.ID,
Short: "Serve the web interface",
Long: `Serve the intake web interface. Long: `Serve the intake web interface.
`, `,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {

View File

@ -8,8 +8,9 @@ import (
) )
var sourceCmd = &cobra.Command{ var sourceCmd = &cobra.Command{
Use: "source", Use: "source",
Short: "Manage sources", GroupID: sourceGroup.ID,
Short: "Manage sources",
Long: `Manage sources. Long: `Manage sources.
A source represents a single content feed that generates discrete feed items. A source represents a single content feed that generates discrete feed items.