Move item commands to top level

This commit is contained in:
Tim Van Baak 2025-03-06 17:30:33 -08:00
parent f6e51a992c
commit 54ded65e72
3 changed files with 16 additions and 32 deletions

View File

@ -1,16 +0,0 @@
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)
}

View File

@ -9,8 +9,8 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var itemAddCmd = &cobra.Command{ var itemCmd = &cobra.Command{
Use: "add", Use: "item",
Short: "Add an item", Short: "Add an item",
Long: `Create an ad-hoc item in a source. Long: `Create an ad-hoc item in a source.
@ -34,19 +34,19 @@ if it doesn't exist, with a random id.`,
} }
func init() { func init() {
itemCmd.AddCommand(itemAddCmd) rootCmd.AddCommand(itemCmd)
itemAddCmd.Flags().StringP("source", "s", "", "Source in which to create the item (default: default)") itemCmd.Flags().StringP("source", "s", "", "Source in which to create the item (default: default)")
itemAddCmd.Flags().StringP("id", "i", "", "Item id (default: random hex)") itemCmd.Flags().StringP("id", "i", "", "Item id (default: random hex)")
itemAddCmd.Flags().StringP("title", "t", "", "Item title") itemCmd.Flags().StringP("title", "t", "", "Item title")
itemAddCmd.Flags().StringP("author", "a", "", "Item author") itemCmd.Flags().StringP("author", "a", "", "Item author")
itemAddCmd.Flags().StringP("body", "b", "", "Item body") itemCmd.Flags().StringP("body", "b", "", "Item body")
itemAddCmd.Flags().StringP("link", "l", "", "Item link") itemCmd.Flags().StringP("link", "l", "", "Item link")
itemAddCmd.Flags().IntP("time", "m", 0, "Item time as a Unix timestamp") itemCmd.Flags().IntP("time", "m", 0, "Item time as a Unix timestamp")
itemAddCmd.Flags().Int("ttl", 0, "Item time-to-live in seconds, relative to item creation date") itemCmd.Flags().Int("ttl", 0, "Item time-to-live in seconds, relative to item creation date")
itemAddCmd.Flags().Int("ttd", 0, "Item time-to-die in seconds, relative to item creation date") itemCmd.Flags().Int("ttd", 0, "Item time-to-die in seconds, relative to item creation date")
itemAddCmd.Flags().Int("tts", 0, "Item time-to-show in seconds, relative to item creation date") itemCmd.Flags().Int("tts", 0, "Item time-to-show in seconds, relative to item creation date")
itemAddCmd.Flags().StringP("action", "x", "", "Item action data as JSON") itemCmd.Flags().StringP("action", "x", "", "Item action data as JSON")
} }
func itemAdd( func itemAdd(

View File

@ -6,7 +6,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var itemEditCmd = &cobra.Command{ var editCmd = &cobra.Command{
Use: "edit", Use: "edit",
Short: "Edit an item", Short: "Edit an item",
Long: ` Long: `
@ -17,5 +17,5 @@ var itemEditCmd = &cobra.Command{
} }
func init() { func init() {
itemCmd.AddCommand(itemEditCmd) rootCmd.AddCommand(editCmd)
} }