MCPcopy
hub / github.com/dnote/dnote / viewNote

Function viewNote

pkg/cli/cmd/view/note.go:28–47  ·  view source on GitHub ↗
(ctx context.DnoteCtx, w io.Writer, noteRowIDArg string, contentOnly bool)

Source from the content-addressed store, hash-verified

26)
27
28func viewNote(ctx context.DnoteCtx, w io.Writer, noteRowIDArg string, contentOnly bool) error {
29 noteRowID, err := strconv.Atoi(noteRowIDArg)
30 if err != nil {
31 return errors.Wrap(err, "invalid rowid")
32 }
33
34 db := ctx.DB
35 info, err := database.GetNoteInfo(db, noteRowID)
36 if err != nil {
37 return err
38 }
39
40 if contentOnly {
41 output.NoteContent(w, info)
42 } else {
43 output.NoteInfo(w, info)
44 }
45
46 return nil
47}

Callers 5

TestViewNoteFunction · 0.85
TestViewNoteContentOnlyFunction · 0.85
TestViewNoteInvalidRowIDFunction · 0.85
TestViewNoteNotFoundFunction · 0.85
newRunFunction · 0.85

Calls 3

GetNoteInfoFunction · 0.92
NoteContentFunction · 0.92
NoteInfoFunction · 0.92

Tested by 4

TestViewNoteFunction · 0.68
TestViewNoteContentOnlyFunction · 0.68
TestViewNoteInvalidRowIDFunction · 0.68
TestViewNoteNotFoundFunction · 0.68