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

Function buildShellCaseBody

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

Source from the content-addressed store, hash-verified

341}
342
343function buildShellCaseBody(
344 map: Map<string, CompletionNode>,
345 select: (node: CompletionNode) => string[],
346): string {
347 const lines: string[] = [' case "$1" in']
348 const entries = [...map.entries()].sort((a, b) => a[0].localeCompare(b[0]))
349
350 for (const [key, node] of entries) {
351 lines.push(` ${shellQuote(key)})`)
352 lines.push(` printf '%s\\n' ${shellQuote(shellWords(select(node)))}`)
353 lines.push(' ;;')
354 }
355
356 lines.push(' *)')
357 lines.push(` printf '%s\\n' ''`)
358 lines.push(' ;;')
359 lines.push(' esac')
360 return lines.join('\n')
361}
362
363function buildFishSwitchBody(
364 map: Map<string, CompletionNode>,

Callers 2

generateBashCompletionFunction · 0.85
generateZshCompletionFunction · 0.85

Calls 4

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

Tested by

no test coverage detected