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

Function peelSubcommand

apps/desktop/src/cli/index.ts:137–154  ·  view source on GitHub ↗
(
  command: string,
  rest: string[]
)

Source from the content-addressed store, hash-verified

135}
136
137function peelSubcommand(
138 command: string,
139 rest: string[]
140): { subcommand: string | null; parsed: ParsedArgs } {
141 const SUBCOMMANDS: Record<string, string[]> = {
142 folder: ['list', 'create', 'rename', 'delete'],
143 tag: ['list', 'find'],
144 task: ['list', 'toggle'],
145 vault: ['info', 'list']
146 }
147 const choices = SUBCOMMANDS[command]
148 if (!choices) return { subcommand: null, parsed: parse(rest) }
149 const sub = rest[0]
150 if (sub == null || !choices.includes(sub)) {
151 return { subcommand: null, parsed: parse(rest) }
152 }
153 return { subcommand: sub, parsed: parse(rest.slice(1)) }
154}
155
156main(process.argv.slice(2)).then(
157 (code) => process.exit(code),

Callers 1

mainFunction · 0.85

Calls 1

parseFunction · 0.70

Tested by

no test coverage detected