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 // editCmd represents the edit command
var editCmd = &cobra.Command{ var editCmd = &cobra.Command{
Use: "edit", Use: "edit",
Short: "A brief description of your command", Short: "Edit the title of a diary entry",
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
Long: `A longer description that spans multiple lines and likely contains examples Long: `
and usage of using your command. For example: Opens a file with the title of the entry. Edit this file to edit the title.
Note that trailing spaces will be trimmed.
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.`,
PreRunE: func(cmd *cobra.Command, args []string) error { PreRunE: func(cmd *cobra.Command, args []string) error {
id, err := strconv.Atoi(args[0]) id, err := strconv.Atoi(args[0])
if err != nil { if err != nil {

@ -9,6 +9,7 @@ import (
"log" "log"
"os" "os"
"strconv" "strconv"
"strings"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -16,14 +17,12 @@ import (
// editNoteCmd represents the editNote command // editNoteCmd represents the editNote command
var editNoteCmd = &cobra.Command{ var editNoteCmd = &cobra.Command{
Use: "note", Use: "note",
Short: "Edit the specified note",
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
Short: "A brief description of your command", Long: `
Long: `A longer description that spans multiple lines and likely contains examples Opens a file with the contents of the note. Edit this file to edit the
and usage of using your command. For example: note. Note that trailing spaces will be trimmed.
`,
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.`,
PreRunE: func(cmd *cobra.Command, args []string) error { PreRunE: func(cmd *cobra.Command, args []string) error {
id, err := strconv.Atoi(args[0]) id, err := strconv.Atoi(args[0])
if err != nil { if err != nil {
@ -57,7 +56,7 @@ to quickly create a Cobra application.`,
if err != nil { if err != nil {
log.Fatal(err) 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 // listCmd represents the list command
var listCmd = &cobra.Command{ var listCmd = &cobra.Command{
Use: "list", Use: "list",
Short: "A brief description of your command", Short: "List all the diary entries, newest first",
Long: `A longer description that spans multiple lines and likely contains examples Long: `List all the entries, starting from the newest.
and usage of using your command. For example: To list the entries added today:
Cobra is a CLI library for Go that empowers applications. $ diary list today
This application is a tool to generate the needed files `,
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
results := App.GetDiaryEntries(model.GetDiaryEntriesQuery{}) results := App.GetDiaryEntries(model.GetDiaryEntriesQuery{})
PrintEntries(results) PrintEntries(results)

@ -16,13 +16,12 @@ import (
var showCmd = &cobra.Command{ var showCmd = &cobra.Command{
Use: "show", Use: "show",
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
Short: "A brief description of your command", Short: "Display a diary entry and its notes",
Long: `A longer description that spans multiple lines and likely contains examples Long: `Display a diary entry and its notes.
and usage of using your command. For example: To disable markdown rendering in the output, pass the --no-markdown flag
(WIP)
Cobra is a CLI library for Go that empowers applications. $ diary show 2 --no-markdown
This application is a tool to generate the needed files `,
to quickly create a Cobra application.`,
PreRunE: func(cmd *cobra.Command, args []string) error { PreRunE: func(cmd *cobra.Command, args []string) error {
id, err := strconv.Atoi(args[0]) id, err := strconv.Atoi(args[0])
if err != nil { if err != nil {

@ -14,13 +14,12 @@ import (
// todayCmd represents the today command // todayCmd represents the today command
var todayCmd = &cobra.Command{ var todayCmd = &cobra.Command{
Use: "today", Use: "today",
Short: "A brief description of your command", Short: "List the diary entries added today, newest first",
Long: `A longer description that spans multiple lines and likely contains examples Long: `List all the entries added today, starting from the newest.
and usage of using your command. For example: To list all the entries:
Cobra is a CLI library for Go that empowers applications. $ diary list
This application is a tool to generate the needed files `,
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
var created_after_ts *int64 = new(int64) var created_after_ts *int64 = new(int64)
var created_before_ts *int64 = new(int64) var created_before_ts *int64 = new(int64)

Loading…
Cancel
Save