NewCmd returns a new add command
(ctx context.DnoteCtx)
| 59 | |
| 60 | // NewCmd returns a new add command |
| 61 | func NewCmd(ctx context.DnoteCtx) *cobra.Command { |
| 62 | cmd := &cobra.Command{ |
| 63 | Use: "add <book>", |
| 64 | Short: "Add a new note", |
| 65 | Aliases: []string{"a", "n", "new"}, |
| 66 | Example: example, |
| 67 | PreRunE: preRun, |
| 68 | RunE: newRun(ctx), |
| 69 | } |
| 70 | |
| 71 | f := cmd.Flags() |
| 72 | f.StringVarP(&contentFlag, "content", "c", "", "The new content for the note") |
| 73 | |
| 74 | return cmd |
| 75 | } |
| 76 | |
| 77 | func getContent(ctx context.DnoteCtx) (string, error) { |
| 78 | if contentFlag != "" { |