( map: Map<string, CompletionNode>, select: (node: CompletionNode) => string[], )
| 361 | } |
| 362 | |
| 363 | function 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 | |
| 381 | function generateBashCompletion(program: CommanderCommand): string { |
| 382 | const map = new Map<string, CompletionNode>() |
no test coverage detected