From 4b32bb67f4d99a1cd8f866e769198a41420c6967 Mon Sep 17 00:00:00 2001 From: isthisnagee Date: Sat, 1 Jan 2022 09:06:18 -0800 Subject: [PATCH] Add short and long descriptions to the commands --- cmd/edit.go | 12 +++++------- cmd/editNote.go | 15 +++++++-------- cmd/list.go | 11 +++++------ cmd/show.go | 13 ++++++------- cmd/today.go | 11 +++++------ 5 files changed, 28 insertions(+), 34 deletions(-) diff --git a/cmd/edit.go b/cmd/edit.go index e7510c8..4b4918e 100644 --- a/cmd/edit.go +++ b/cmd/edit.go @@ -16,14 +16,12 @@ import ( // editCmd represents the edit command var editCmd = &cobra.Command{ Use: "edit", - Short: "A brief description of your command", + Short: "Edit the title of a diary entry", Args: cobra.ExactArgs(1), - 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.`, + Long: ` + Opens a file with the title of the entry. Edit this file to edit the title. + Note that trailing spaces will be trimmed. + `, PreRunE: func(cmd *cobra.Command, args []string) error { id, err := strconv.Atoi(args[0]) if err != nil { diff --git a/cmd/editNote.go b/cmd/editNote.go index 297001b..6123f8f 100644 --- a/cmd/editNote.go +++ b/cmd/editNote.go @@ -9,6 +9,7 @@ import ( "log" "os" "strconv" + "strings" "github.com/spf13/cobra" ) @@ -16,14 +17,12 @@ import ( // editNoteCmd represents the editNote command var editNoteCmd = &cobra.Command{ Use: "note", + Short: "Edit the specified note", Args: cobra.ExactArgs(1), - Short: "A brief description of your command", - 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.`, + Long: ` + Opens a file with the contents of the note. Edit this file to edit the + note. Note that trailing spaces will be trimmed. + `, PreRunE: func(cmd *cobra.Command, args []string) error { id, err := strconv.Atoi(args[0]) if err != nil { @@ -57,7 +56,7 @@ to quickly create a Cobra application.`, if err != nil { log.Fatal(err) } - App.EditDiaryEntryNote(note.Id, string(new_content)) + App.EditDiaryEntryNote(note.Id, strings.TrimSpace(string(new_content))) }, } diff --git a/cmd/list.go b/cmd/list.go index 797cb2c..1c2fc92 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -13,13 +13,12 @@ import ( // listCmd represents the list command var listCmd = &cobra.Command{ Use: "list", - Short: "A brief description of your command", - Long: `A longer description that spans multiple lines and likely contains examples -and usage of using your command. For example: + Short: "List all the diary entries, newest first", + Long: `List all the entries, starting from the newest. + To list the entries added today: -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.`, + $ diary list today + `, Run: func(cmd *cobra.Command, args []string) { results := App.GetDiaryEntries(model.GetDiaryEntriesQuery{}) PrintEntries(results) diff --git a/cmd/show.go b/cmd/show.go index 096d2d7..5fead7b 100644 --- a/cmd/show.go +++ b/cmd/show.go @@ -16,13 +16,12 @@ import ( var showCmd = &cobra.Command{ Use: "show", Args: cobra.ExactArgs(1), - Short: "A brief description of your command", - 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.`, + Short: "Display a diary entry and its notes", + Long: `Display a diary entry and its notes. + To disable markdown rendering in the output, pass the --no-markdown flag + (WIP) + $ diary show 2 --no-markdown + `, PreRunE: func(cmd *cobra.Command, args []string) error { id, err := strconv.Atoi(args[0]) if err != nil { diff --git a/cmd/today.go b/cmd/today.go index e3ce78c..c50b0bf 100644 --- a/cmd/today.go +++ b/cmd/today.go @@ -14,13 +14,12 @@ import ( // todayCmd represents the today command var todayCmd = &cobra.Command{ Use: "today", - Short: "A brief description of your command", - Long: `A longer description that spans multiple lines and likely contains examples -and usage of using your command. For example: + Short: "List the diary entries added today, newest first", + Long: `List all the entries added today, starting from the newest. + To list all the entries: -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.`, + $ diary list + `, Run: func(cmd *cobra.Command, args []string) { var created_after_ts *int64 = new(int64) var created_before_ts *int64 = new(int64)