MCPcopy
hub / github.com/dnote/dnote / NewCmd

Function NewCmd

pkg/cli/cmd/remove/remove.go:46–63  ·  view source on GitHub ↗

NewCmd returns a new remove command

(ctx context.DnoteCtx)

Source from the content-addressed store, hash-verified

44
45// NewCmd returns a new remove command
46func NewCmd(ctx context.DnoteCtx) *cobra.Command {
47 cmd := &cobra.Command{
48 Use: "remove <note id|book name>",
49 Short: "Remove a note or a book",
50 Aliases: []string{"rm", "d", "delete"},
51 Example: example,
52 PreRunE: preRun,
53 RunE: newRun(ctx),
54 }
55
56 f := cmd.Flags()
57 f.StringVarP(&bookFlag, "book", "b", "", "The book name to delete")
58 f.BoolVarP(&yesFlag, "yes", "y", false, "Assume yes to the prompts and run in non-interactive mode")
59
60 f.MarkDeprecated("book", "Pass the book name as an argument. e.g. `dnote rm book_name`")
61
62 return cmd
63}
64
65func preRun(cmd *cobra.Command, args []string) error {
66 if len(args) != 1 && len(args) != 2 {

Callers 1

mainFunction · 0.92

Calls 1

newRunFunction · 0.70

Tested by

no test coverage detected