MCPcopy Create free account
hub / github.com/Noumena-Network/code / buildFishSwitchBody

Function buildFishSwitchBody

src/cli/handlers/ant.ts:363–379  ·  view source on GitHub ↗
(
  map: Map<string, CompletionNode>,
  select: (node: CompletionNode) => string[],
)

Source from the content-addressed store, hash-verified

361}
362
363function buildFishSwitchBody(
364 map: Map<string, CompletionNode>,
365 select: (node: CompletionNode) => string[],
366): string {
367 const lines: string[] = [' switch $argv[1]']
368 const entries = [...map.entries()].sort((a, b) => a[0].localeCompare(b[0]))
369
370 for (const [key, node] of entries) {
371 lines.push(` case ${shellQuote(key)}`)
372 lines.push(` printf '%s\\n' ${shellQuote(shellWords(select(node)))}`)
373 }
374
375 lines.push(` case '*'`)
376 lines.push(` printf '%s\\n' ''`)
377 lines.push(' end')
378 return lines.join('\n')
379}
380
381function generateBashCompletion(program: CommanderCommand): string {
382 const map = new Map<string, CompletionNode>()

Callers 1

generateFishCompletionFunction · 0.85

Calls 4

shellWordsFunction · 0.85
selectFunction · 0.85
entriesMethod · 0.80
shellQuoteFunction · 0.70

Tested by

no test coverage detected