( map: Map<string, CompletionNode>, select: (node: CompletionNode) => string[], )
| 341 | } |
| 342 | |
| 343 | function 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 | |
| 363 | function buildFishSwitchBody( |
| 364 | map: Map<string, CompletionNode>, |
no test coverage detected