From b5db233263fbd554a47f648496b0cb2fe7baa4f0 Mon Sep 17 00:00:00 2001 From: fiplox Date: Sat, 10 Sep 2022 21:34:14 +0200 Subject: [PATCH] change long descriptions --- cmd/ed.go | 12 ++++++------ cmd/ls.go | 10 +++++----- cmd/new.go | 7 ++----- cmd/rm.go | 12 +++--------- cmd/root.go | 11 ++++------- 5 files changed, 20 insertions(+), 32 deletions(-) diff --git a/cmd/ed.go b/cmd/ed.go index b5c98ea..b2f572c 100644 --- a/cmd/ed.go +++ b/cmd/ed.go @@ -25,14 +25,14 @@ import ( // edCmd represents the ed command var edCmd = &cobra.Command{ - Use: "ed", + Use: "ed [id]", Short: "Edit a todo", - Long: `A longer description that spans multiple lines and likely contains examples -and usage of using your command. For example: + Long: `Edit a todo giving an ID as arg1, then all args are +taken as a string. -Cobra is a CLI library for Go that empowers applications. -This application is a tool to generate the needed files -to quickly create a Cobra application.`, +You can edit a due date with '-d DATE'. +You can mark a todo as completed with '-c'. +`, Args: func(cmd *cobra.Command, args []string) error { if cmd.Flags().NFlag() >= 1 { if err := cobra.MinimumNArgs(1)(cmd, args); err != nil { diff --git a/cmd/ls.go b/cmd/ls.go index 08658de..bf0ba35 100644 --- a/cmd/ls.go +++ b/cmd/ls.go @@ -30,12 +30,12 @@ import ( var lsCmd = &cobra.Command{ Use: "ls", Short: "List todos", - Long: `A longer description that spans multiple lines and likely contains examples -and usage of using your command. For example: + Long: `List todos. By default, lists uncompleted todos. -Cobra is a CLI library for Go that empowers applications. -This application is a tool to generate the needed files -to quickly create a Cobra application.`, +If given '-c' flag, lists completed todos. +Otherwise, you can list all todos with '-a'. + +You can list showing all fields with '-v'.`, Run: func(cmd *cobra.Command, args []string) { var todos []Todo all, err := cmd.Flags().GetBool("all") diff --git a/cmd/new.go b/cmd/new.go index f4cc0c5..12d1a62 100644 --- a/cmd/new.go +++ b/cmd/new.go @@ -40,12 +40,9 @@ func sliceAtoi(s []string) []int { var newCmd = &cobra.Command{ Use: "new", Short: "Create new todo", - Long: `A longer description that spans multiple lines and likely contains examples -and usage of using your command. For example: + Long: `Create new todo with optional due date using '-d DATE'. -Cobra is a CLI library for Go that empowers applications. -This application is a tool to generate the needed files -to quickly create a Cobra application.`, +You can also mark todo as completed when creating it with '-c'.`, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { dateString, err := cmd.Flags().GetString("due") diff --git a/cmd/rm.go b/cmd/rm.go index 8cf6daa..93cf81c 100644 --- a/cmd/rm.go +++ b/cmd/rm.go @@ -24,15 +24,10 @@ import ( // rmCmd represents the rm command var rmCmd = &cobra.Command{ - Use: "rm", + Use: "rm [id]", Short: "Remove a todo", - Long: `A longer description that spans multiple lines and likely contains examples -and usage of using your command. For example: - -Cobra is a CLI library for Go that empowers applications. -This application is a tool to generate the needed files -to quickly create a Cobra application.`, - Args: cobra.MinimumNArgs(1), + Long: `Remove a todo given its id.`, + Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { id, err := strconv.ParseUint(args[0], 10, 0) errPanic(err, "failed to parse uint") @@ -42,5 +37,4 @@ to quickly create a Cobra application.`, func init() { rootCmd.AddCommand(rmCmd) - } diff --git a/cmd/root.go b/cmd/root.go index e2309fc..70cd81e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -26,14 +26,11 @@ import ( var rootCmd = &cobra.Command{ Use: "todo", Short: "Minimal todo app", - Long: `A longer description that spans multiple lines and likely contains -examples and usage of using your application. For example: + Long: `Minimal todo app which lets you create, +remove, edit and list your todos. -Cobra is a CLI library for Go that empowers applications. -This application is a tool to generate the needed files -to quickly create a Cobra application.`, - // Uncomment the following line if your bare application - // has an action associated with it: +You can optionally add due date and mark todo as completed. +Running without flags lists all uncompleted todos.`, Run: lsCmd.Run, }