(shell: string, program: Command)
| 5 | * Generate shell completion script for the given shell. |
| 6 | */ |
| 7 | export function generateCompletionScript(shell: string, program: Command): string | null { |
| 8 | const commands = program.commands.map(cmd => cmd.name()).filter(name => name !== 'help') |
| 9 | |
| 10 | switch (shell.toLowerCase()) { |
| 11 | case 'bash': |
| 12 | return generateBashCompletion(commands) |
| 13 | case 'zsh': |
| 14 | return generateZshCompletion(commands) |
| 15 | case 'fish': |
| 16 | return generateFishCompletion(commands) |
| 17 | default: |
| 18 | return null |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | function generateBashCompletion(commands: string[]): string { |
| 23 | const blockTypes = FILTERABLE_BLOCK_TYPES.join(' ') |
no test coverage detected