MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / cmdList

Function cmdList

apps/desktop/src/cli/commands/notes.ts:47–78  ·  view source on GitHub ↗
(vault: string, args: ParsedArgs)

Source from the content-addressed store, hash-verified

45}
46
47export async function cmdList(vault: string, args: ParsedArgs): Promise<void> {
48 const folder = parseFolderFlag(getString(args, 'folder'))
49 const tag = getString(args, 'tag')?.toLowerCase()
50 const limit = getNumber(args, 'limit') ?? 50
51 let notes = await listNotes(vault)
52 notes = folder
53 ? notes.filter((n) => n.folder === folder)
54 : notes.filter((n) => n.folder !== 'trash')
55 if (tag) {
56 notes = notes.filter((n) =>
57 n.tags.map((t) => t.toLowerCase()).includes(tag.replace(/^#/, ''))
58 )
59 }
60 notes.sort((a, b) => b.updatedAt - a.updatedAt)
61 notes = notes.slice(0, limit)
62
63 if (getBool(args, 'json')) {
64 emitJson(notes)
65 return
66 }
67 if (notes.length === 0) {
68 emitLine('No notes found.')
69 return
70 }
71 // Two-column terse layout: "<age> <folder> <path>".
72 const widestFolder = notes.reduce((w, n) => Math.max(w, n.folder.length), 0)
73 for (const n of notes) {
74 emitLine(
75 `${pad(formatRelativeAge(n.updatedAt), 10)} ${pad(n.folder, widestFolder)} ${n.path}`
76 )
77 }
78}
79
80export async function cmdRead(vault: string, args: ParsedArgs): Promise<void> {
81 const rel = requirePath(args)

Callers

nothing calls this directly

Calls 9

padFunction · 0.90
parseFolderFlagFunction · 0.85
getStringFunction · 0.85
getNumberFunction · 0.85
getBoolFunction · 0.85
emitJsonFunction · 0.85
emitLineFunction · 0.85
listNotesFunction · 0.50
formatRelativeAgeFunction · 0.50

Tested by

no test coverage detected