MCPcopy Index your code
hub / github.com/dnote/dnote / newRun

Function newRun

pkg/cli/cmd/remove/remove.go:81–118  ·  view source on GitHub ↗
(ctx context.DnoteCtx)

Source from the content-addressed store, hash-verified

79}
80
81func newRun(ctx context.DnoteCtx) infra.RunEFunc {
82 return func(cmd *cobra.Command, args []string) error {
83 // DEPRECATED: Remove in 1.0.0
84 if bookFlag != "" {
85 if err := runBook(ctx, bookFlag); err != nil {
86 return errors.Wrap(err, "removing the book")
87 }
88
89 return nil
90 }
91
92 // DEPRECATED: Remove in 1.0.0
93 if len(args) == 2 {
94 log.Plain(log.ColorYellow.Sprintf("DEPRECATED: you no longer need to pass book name to the remove command. e.g. `dnote remove 123`.\n\n"))
95
96 target := args[1]
97 if err := runNote(ctx, target); err != nil {
98 return errors.Wrap(err, "removing the note")
99 }
100
101 return nil
102 }
103
104 target := args[0]
105
106 if utils.IsNumber(target) {
107 if err := runNote(ctx, target); err != nil {
108 return errors.Wrap(err, "removing the note")
109 }
110 } else {
111 if err := runBook(ctx, target); err != nil {
112 return errors.Wrap(err, "removing the book")
113 }
114 }
115
116 return nil
117 }
118}
119
120func runNote(ctx context.DnoteCtx, rowIDArg string) error {
121 db := ctx.DB

Callers 1

NewCmdFunction · 0.70

Calls 4

PlainFunction · 0.92
IsNumberFunction · 0.92
runBookFunction · 0.70
runNoteFunction · 0.70

Tested by

no test coverage detected