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

Function cmdVaultList

apps/desktop/src/cli/commands/vault.ts:48–76  ·  view source on GitHub ↗
(_vault: string, args: ParsedArgs)

Source from the content-addressed store, hash-verified

46}
47
48export async function cmdVaultList(_vault: string, args: ParsedArgs): Promise<void> {
49 const known = await readKnownVaultsFromConfig()
50 // The vault commands without --vault would use this one — mark it.
51 const defaultRoot = await resolveVaultRoot().catch(() => null)
52
53 const entries = known.map((vault) => ({
54 name: vault.name,
55 root: vault.root,
56 lastOpenedAt: vault.lastOpenedAt,
57 isDefault: defaultRoot !== null && path.resolve(vault.root) === defaultRoot
58 }))
59
60 if (getBool(args, 'json')) {
61 emitJson(entries)
62 return
63 }
64
65 if (entries.length === 0) {
66 emitLine('No vaults known yet. Open one in ZenNotes, or pass --vault <path>.')
67 return
68 }
69
70 const nameWidth = Math.max(...entries.map((entry) => entry.name.length), 4)
71 for (const entry of entries) {
72 const marker = entry.isDefault ? '*' : ' '
73 const age = entry.lastOpenedAt != null ? formatRelativeAge(entry.lastOpenedAt) : ''
74 emitLine(`${marker} ${pad(entry.name, nameWidth)} ${pad(age, 8)} ${entry.root}`)
75 }
76}

Callers 1

vault.test.tsFile · 0.90

Calls 7

padFunction · 0.90
resolveVaultRootFunction · 0.85
getBoolFunction · 0.85
emitJsonFunction · 0.85
emitLineFunction · 0.85
formatRelativeAgeFunction · 0.50

Tested by

no test coverage detected