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

Function newRun

pkg/cli/cmd/edit/edit.go:75–104  ·  view source on GitHub ↗
(ctx context.DnoteCtx)

Source from the content-addressed store, hash-verified

73}
74
75func newRun(ctx context.DnoteCtx) infra.RunEFunc {
76 return func(cmd *cobra.Command, args []string) error {
77 // DEPRECATED: Remove in 1.0.0
78 if len(args) == 2 {
79 log.Plain(log.ColorYellow.Sprintf("DEPRECATED: you no longer need to pass book name to the view command. e.g. `dnote view 123`.\n\n"))
80
81 target := args[1]
82
83 if err := runNote(ctx, target); err != nil {
84 return errors.Wrap(err, "editing note")
85 }
86
87 return nil
88 }
89
90 target := args[0]
91
92 if utils.IsNumber(target) {
93 if err := runNote(ctx, target); err != nil {
94 return errors.Wrap(err, "editing note")
95 }
96 } else {
97 if err := runBook(ctx, target); err != nil {
98 return errors.Wrap(err, "editing book")
99 }
100 }
101
102 return nil
103 }
104}

Callers 1

NewCmdFunction · 0.70

Calls 4

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

Tested by

no test coverage detected