NewCmd returns a new view command
(ctx context.DnoteCtx)
| 49 | |
| 50 | // NewCmd returns a new view command |
| 51 | func NewCmd(ctx context.DnoteCtx) *cobra.Command { |
| 52 | cmd := &cobra.Command{ |
| 53 | Use: "view <book name?> <note index?>", |
| 54 | Aliases: []string{"v"}, |
| 55 | Short: "List books, notes or view a content", |
| 56 | Example: example, |
| 57 | RunE: newRun(ctx), |
| 58 | PreRunE: preRun, |
| 59 | } |
| 60 | |
| 61 | f := cmd.Flags() |
| 62 | f.BoolVarP(&nameOnly, "name-only", "", false, "print book names only") |
| 63 | f.BoolVarP(&contentOnly, "content-only", "", false, "print the note content only") |
| 64 | |
| 65 | return cmd |
| 66 | } |
| 67 | |
| 68 | func newRun(ctx context.DnoteCtx) infra.RunEFunc { |
| 69 | return func(cmd *cobra.Command, args []string) error { |