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