Add short and long descriptions to the commands

pull/8/head
isthisnagee 3 years ago
parent 3760466b31
commit 4b32bb67f4

@ -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 {

@ -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)))
},
}

@ -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)

@ -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 {

@ -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)

Loading…
Cancel
Save