-
Notifications
You must be signed in to change notification settings - Fork 33
feat: add shell completion command for bash, zsh, and fish #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
5403f30
6616a03
268d34d
d20a9da
c394790
34eb43b
632a194
fe3ddf4
21dae8a
233342b
6efcf1a
865ca06
f54a72c
2fbc1a7
29f98e2
752d122
b9c8353
64fa578
aae46e6
86b3c93
a694339
5ba5e16
7393773
bc5522e
06dc7b6
7830ea7
d89054b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,277 @@ | ||||||||||||||||||||||||||||||||||||
| import pc from 'picocolors'; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const BASH_SCRIPT = `#!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||
| # bash completion for commit-echo -*- shell-script -*- | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| _commit_echo() | ||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||
| local cur prev commands | ||||||||||||||||||||||||||||||||||||
| COMPREPLY=() | ||||||||||||||||||||||||||||||||||||
| cur="\${COMP_WORDS[COMP_CWORD]}" | ||||||||||||||||||||||||||||||||||||
| prev="\${COMP_WORDS[COMP_CWORD-1]}" | ||||||||||||||||||||||||||||||||||||
| commands="init config suggest history batch completion help" | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # Global options | ||||||||||||||||||||||||||||||||||||
| global_opts="--yes --auto --no-color --help --version" | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if [[ "\${cur}" == -* ]]; then | ||||||||||||||||||||||||||||||||||||
| COMPREPLY=( $(compgen -W "\${global_opts}" -- "\${cur}") ) | ||||||||||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # If we're the second word, complete subcommands | ||||||||||||||||||||||||||||||||||||
| if [[ "\${COMP_CWORD}" -eq 1 ]]; then | ||||||||||||||||||||||||||||||||||||
| COMPREPLY=( $(compgen -W "\${commands}" -- "\${cur}") ) | ||||||||||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| local subcmd="\${COMP_WORDS[1]}" | ||||||||||||||||||||||||||||||||||||
| case "\${subcmd}" in | ||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||||||||||
| suggest) | ||||||||||||||||||||||||||||||||||||
| local suggest_opts="--commit --yes --verbose --model --stream --dry-run --no-commit --auto --help" | ||||||||||||||||||||||||||||||||||||
| if [[ "\${cur}" == -* ]]; then | ||||||||||||||||||||||||||||||||||||
| COMPREPLY=( $(compgen -W "\${suggest_opts}" -- "\${cur}") ) | ||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||
| history) | ||||||||||||||||||||||||||||||||||||
| local history_opts="--json --help" | ||||||||||||||||||||||||||||||||||||
| if [[ "\${cur}" == -* ]]; then | ||||||||||||||||||||||||||||||||||||
| COMPREPLY=( $(compgen -W "\${history_opts}" -- "\${cur}") ) | ||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||
| batch) | ||||||||||||||||||||||||||||||||||||
| local batch_opts="--recursive --yes --auto --help" | ||||||||||||||||||||||||||||||||||||
| if [[ "\${cur}" == -* ]]; then | ||||||||||||||||||||||||||||||||||||
| COMPREPLY=( $(compgen -W "\${batch_opts}" -- "\${cur}") ) | ||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||
| init) | ||||||||||||||||||||||||||||||||||||
| local init_opts="--install-hook --help" | ||||||||||||||||||||||||||||||||||||
| if [[ "\${cur}" == -* ]]; then | ||||||||||||||||||||||||||||||||||||
| COMPREPLY=( $(compgen -W "\${init_opts}" -- "\${cur}") ) | ||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||
| completion) | ||||||||||||||||||||||||||||||||||||
| local completion_opts="--help" | ||||||||||||||||||||||||||||||||||||
| if [[ "\${cur}" == -* ]]; then | ||||||||||||||||||||||||||||||||||||
| COMPREPLY=( $(compgen -W "\${completion_opts}" -- "\${cur}") ) | ||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||
| COMPREPLY=( $(compgen -W "bash zsh fish" -- "\${cur}") ) | ||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||
| esac | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| complete -F _commit_echo commit-echo | ||||||||||||||||||||||||||||||||||||
| `; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const ZSH_SCRIPT = `#compdef commit-echo | ||||||||||||||||||||||||||||||||||||
| # zsh completion for commit-echo -*- shell-script -*- | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| _commit_echo() { | ||||||||||||||||||||||||||||||||||||
| local -a commands | ||||||||||||||||||||||||||||||||||||
| commands=( | ||||||||||||||||||||||||||||||||||||
| 'init:Run interactive setup wizard' | ||||||||||||||||||||||||||||||||||||
| 'config:View current configuration' | ||||||||||||||||||||||||||||||||||||
| 'suggest:Generate commit suggestions' | ||||||||||||||||||||||||||||||||||||
| 'history:View learned style profile and recent commit history' | ||||||||||||||||||||||||||||||||||||
| 'batch:Process multiple git repositories in batch mode' | ||||||||||||||||||||||||||||||||||||
| 'completion:Generate shell completion scripts' | ||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+290
to
+292
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Zsh omits the Bash and fish both advertise Suggested fix commands=(
'init:Run interactive setup wizard'
'config:View current configuration'
'suggest:Generate commit suggestions'
'history:View learned style profile and recent commit history'
'batch:Process multiple git repositories in batch mode'
'completion:Generate shell completion scripts'
+ 'help:Display help'
)📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚪ LOW RISK Suggestion: Add |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| _arguments -C \\ | ||||||||||||||||||||||||||||||||||||
| '--yes[Automatically accept the first suggestion and commit without prompts]' \\ | ||||||||||||||||||||||||||||||||||||
| '--auto[Alias for --yes]' \\ | ||||||||||||||||||||||||||||||||||||
| '--no-color[Disable colored output]' \\ | ||||||||||||||||||||||||||||||||||||
| '--version[Output the version]' \\ | ||||||||||||||||||||||||||||||||||||
| '--help[Display help]' \\ | ||||||||||||||||||||||||||||||||||||
| '1:command:->command' \\ | ||||||||||||||||||||||||||||||||||||
| '*::args:->args' | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| case \$state in | ||||||||||||||||||||||||||||||||||||
| command) | ||||||||||||||||||||||||||||||||||||
| _describe 'command' commands | ||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||
| args) | ||||||||||||||||||||||||||||||||||||
| case \$words[1] in | ||||||||||||||||||||||||||||||||||||
| suggest) | ||||||||||||||||||||||||||||||||||||
| _arguments \\ | ||||||||||||||||||||||||||||||||||||
| '--commit[Commit the selected suggestion]' \\ | ||||||||||||||||||||||||||||||||||||
| '--yes[Automatically select the first suggestion and skip prompts]' \\ | ||||||||||||||||||||||||||||||||||||
| '--verbose[Print diagnostic information about the suggestion request]' \\ | ||||||||||||||||||||||||||||||||||||
| '--model[Override the configured LLM model]:model:' \\ | ||||||||||||||||||||||||||||||||||||
| '--stream[Stream suggestions as they are generated]' \\ | ||||||||||||||||||||||||||||||||||||
| '--dry-run[Show the LLM input without generating suggestions]' \\ | ||||||||||||||||||||||||||||||||||||
| '--no-commit[Deprecated alias]' \\ | ||||||||||||||||||||||||||||||||||||
| '--auto[Alias for --yes]' \\ | ||||||||||||||||||||||||||||||||||||
| '--help[Display help for suggest]' | ||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||
| history) | ||||||||||||||||||||||||||||||||||||
| _arguments \\ | ||||||||||||||||||||||||||||||||||||
| '--json[Output the style profile and recent commits as JSON]' \\ | ||||||||||||||||||||||||||||||||||||
| '--help[Display help for history]' | ||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||
| batch) | ||||||||||||||||||||||||||||||||||||
| _arguments \\ | ||||||||||||||||||||||||||||||||||||
| '--recursive[Recursively search subdirectories for git repos]' \\ | ||||||||||||||||||||||||||||||||||||
| '--yes[Automatically accept the first suggestion and commit without prompts]' \\ | ||||||||||||||||||||||||||||||||||||
| '--auto[Alias for --yes]' \\ | ||||||||||||||||||||||||||||||||||||
| '--help[Display help for batch]' | ||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||
| init) | ||||||||||||||||||||||||||||||||||||
| _arguments \\ | ||||||||||||||||||||||||||||||||||||
| '--install-hook[Install a prepare-commit-msg hook in the current repository]' \\ | ||||||||||||||||||||||||||||||||||||
| '--help[Display help for init]' | ||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||
| completion) | ||||||||||||||||||||||||||||||||||||
| _arguments \\ | ||||||||||||||||||||||||||||||||||||
| '--help[Display help for completion]' \\ | ||||||||||||||||||||||||||||||||||||
| '1:shell:(bash zsh fish)' | ||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||
| esac | ||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||
| esac | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| _compdef _commit_echo commit-echo | ||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 HIGH RISK The command
Suggested change
|
||||||||||||||||||||||||||||||||||||
| `; | ||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 HIGH RISK The registration command uses |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const FISH_SCRIPT = `# fish completion for commit-echo -*- shell-script -*- | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # Helper: complete options for a subcommand | ||||||||||||||||||||||||||||||||||||
| function __commit_echo_complete_options | ||||||||||||||||||||||||||||||||||||
| set -l cmd (commandline -opc) | ||||||||||||||||||||||||||||||||||||
| set -l subcmd $cmd[2] | ||||||||||||||||||||||||||||||||||||
| switch $subcmd | ||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||||||||||
| case suggest | ||||||||||||||||||||||||||||||||||||
| printf '%s\\t%s\\n' \\ | ||||||||||||||||||||||||||||||||||||
| '--commit\\tCommit the selected suggestion' \\ | ||||||||||||||||||||||||||||||||||||
| '--yes\\tAutomatically select the first suggestion' \\ | ||||||||||||||||||||||||||||||||||||
| '--verbose\\tPrint diagnostic information' \\ | ||||||||||||||||||||||||||||||||||||
| '--model\\tOverride the configured LLM model' \\ | ||||||||||||||||||||||||||||||||||||
| '--stream\\tStream suggestions as they are generated' \\ | ||||||||||||||||||||||||||||||||||||
| '--dry-run\\tShow the LLM input without generating suggestions' \\ | ||||||||||||||||||||||||||||||||||||
| '--no-commit\\tDeprecated alias' \\ | ||||||||||||||||||||||||||||||||||||
| '--auto\\tAlias for --yes' \\ | ||||||||||||||||||||||||||||||||||||
| '--help\\tDisplay help' | ||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Fish completion entries are emitted with the wrong These arguments already contain Suggested fix- printf '%s\t%s\n' \
+ printf '%s\n' \
'--commit\tCommit the selected suggestion' \
'--yes\tAutomatically select the first suggestion' \
'--verbose\tPrint diagnostic information' \Apply the same format-string change to the other fish completion 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
| case history | ||||||||||||||||||||||||||||||||||||
| printf '%s\\t%s\\n' \\ | ||||||||||||||||||||||||||||||||||||
| '--json\\tOutput the style profile and recent commits as JSON' \\ | ||||||||||||||||||||||||||||||||||||
| '--help\\tDisplay help' | ||||||||||||||||||||||||||||||||||||
| case batch | ||||||||||||||||||||||||||||||||||||
| printf '%s\\t%s\\n' \\ | ||||||||||||||||||||||||||||||||||||
| '--recursive\\tRecursively search subdirectories for git repos' \\ | ||||||||||||||||||||||||||||||||||||
| '--yes\\tAutomatically accept the first suggestion and commit without prompts' \\ | ||||||||||||||||||||||||||||||||||||
| '--auto\\tAlias for --yes' \\ | ||||||||||||||||||||||||||||||||||||
| '--help\\tDisplay help' | ||||||||||||||||||||||||||||||||||||
| case init | ||||||||||||||||||||||||||||||||||||
| printf '%s\\t%s\\n' \\ | ||||||||||||||||||||||||||||||||||||
| '--install-hook\\tInstall a prepare-commit-msg hook' \\ | ||||||||||||||||||||||||||||||||||||
| '--help\\tDisplay help' | ||||||||||||||||||||||||||||||||||||
| case completion | ||||||||||||||||||||||||||||||||||||
| printf '%s\\t%s\\n' \\ | ||||||||||||||||||||||||||||||||||||
| '--help\\tDisplay help' | ||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| function __commit_echo_subcommands | ||||||||||||||||||||||||||||||||||||
| printf '%s\\t%s\\n' \\ | ||||||||||||||||||||||||||||||||||||
| 'init\\tRun interactive setup wizard' \\ | ||||||||||||||||||||||||||||||||||||
| 'config\\tView current configuration' \\ | ||||||||||||||||||||||||||||||||||||
| 'suggest\\tGenerate commit suggestions' \\ | ||||||||||||||||||||||||||||||||||||
| 'history\\tView learned style profile and history' \\ | ||||||||||||||||||||||||||||||||||||
| 'batch\\tProcess multiple git repositories' \\ | ||||||||||||||||||||||||||||||||||||
| 'completion\\tGenerate shell completion scripts' \\ | ||||||||||||||||||||||||||||||||||||
| 'help\\tDisplay help' | ||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| function __commit_echo_completions | ||||||||||||||||||||||||||||||||||||
| set -l cmd (commandline -opc) | ||||||||||||||||||||||||||||||||||||
| set -l argc (count $cmd) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # If we are at position 1 (just the program name), suggest subcommands | ||||||||||||||||||||||||||||||||||||
| if test $argc -eq 1 | ||||||||||||||||||||||||||||||||||||
| __commit_echo_subcommands | ||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # If the previous token is a flag with a value (like --model), don't complete | ||||||||||||||||||||||||||||||||||||
| switch $cmd[-1] | ||||||||||||||||||||||||||||||||||||
| case '--model' | ||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # If the current token starts with -, suggest global + subcommand options | ||||||||||||||||||||||||||||||||||||
| set -l token (commandline -ct) | ||||||||||||||||||||||||||||||||||||
| if string match -q -- '-*' $token | ||||||||||||||||||||||||||||||||||||
| # Global options | ||||||||||||||||||||||||||||||||||||
| printf '%s\\t%s\\n' \\ | ||||||||||||||||||||||||||||||||||||
| '--yes\\tAutomatically accept the first suggestion' \\ | ||||||||||||||||||||||||||||||||||||
| '--auto\\tAlias for --yes' \\ | ||||||||||||||||||||||||||||||||||||
| '--no-color\\tDisable colored output' \\ | ||||||||||||||||||||||||||||||||||||
| '--version\\tOutput the version' \\ | ||||||||||||||||||||||||||||||||||||
| '--help\\tDisplay help' | ||||||||||||||||||||||||||||||||||||
| # Subcommand options | ||||||||||||||||||||||||||||||||||||
| __commit_echo_complete_options | ||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # Otherwise, suggest subcommands | ||||||||||||||||||||||||||||||||||||
| __commit_echo_subcommands | ||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 MEDIUM RISK In the Fish completion script, subcommands are suggested even when one has already been specified. Only suggest subcommands if no subcommand has been identified yet. Wrap the call to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 MEDIUM RISK The script suggests all subcommands even when one has already been selected. It should only suggest subcommands if the |
||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| complete -c commit-echo -f -a '(__commit_echo_completions)' | ||||||||||||||||||||||||||||||||||||
| `; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| export type SupportedShell = 'bash' | 'zsh' | 'fish'; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const VALID_SHELLS: SupportedShell[] = ['bash', 'zsh', 'fish']; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| /** Returns the completion script for the given shell. */ | ||||||||||||||||||||||||||||||||||||
| function getCompletionScript(shell: SupportedShell): string { | ||||||||||||||||||||||||||||||||||||
| switch (shell) { | ||||||||||||||||||||||||||||||||||||
| case 'bash': | ||||||||||||||||||||||||||||||||||||
| return BASH_SCRIPT; | ||||||||||||||||||||||||||||||||||||
| case 'zsh': | ||||||||||||||||||||||||||||||||||||
| return ZSH_SCRIPT; | ||||||||||||||||||||||||||||||||||||
| case 'fish': | ||||||||||||||||||||||||||||||||||||
| return FISH_SCRIPT; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| /** Prints a help message showing available shell targets. */ | ||||||||||||||||||||||||||||||||||||
| function printHelp(): void { | ||||||||||||||||||||||||||||||||||||
| console.log(pc.bold('Generate shell completion scripts for commit-echo.\n')); | ||||||||||||||||||||||||||||||||||||
| console.log(pc.cyan('Usage:')); | ||||||||||||||||||||||||||||||||||||
| console.log(' commit-echo completion <shell>\n'); | ||||||||||||||||||||||||||||||||||||
| console.log(pc.cyan('Supported shells:')); | ||||||||||||||||||||||||||||||||||||
| console.log(` ${pc.green('bash')} - Bash completion script`); | ||||||||||||||||||||||||||||||||||||
| console.log(` ${pc.green('zsh')} - Zsh completion script`); | ||||||||||||||||||||||||||||||||||||
| console.log(` ${pc.green('fish')} - Fish completion script\n`); | ||||||||||||||||||||||||||||||||||||
| console.log(pc.cyan('Examples:')); | ||||||||||||||||||||||||||||||||||||
| console.log(` ${pc.dim('# Bash')}`); | ||||||||||||||||||||||||||||||||||||
| console.log(' commit-echo completion bash >> ~/.bashrc\n'); | ||||||||||||||||||||||||||||||||||||
| console.log(` ${pc.dim('# Zsh')}`); | ||||||||||||||||||||||||||||||||||||
| console.log(' commit-echo completion zsh > ~/.zfunc/_commit-echo\n'); | ||||||||||||||||||||||||||||||||||||
| console.log(` ${pc.dim('# Fish')}`); | ||||||||||||||||||||||||||||||||||||
| console.log(' commit-echo completion fish > ~/.config/fish/completions/commit-echo.fish'); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| /** The completion command action: outputs the requested shell script. */ | ||||||||||||||||||||||||||||||||||||
| export function completionCommand(shell?: string): void { | ||||||||||||||||||||||||||||||||||||
| if (!shell) { | ||||||||||||||||||||||||||||||||||||
| printHelp(); | ||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const normalized = shell.toLowerCase() as SupportedShell; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if (!VALID_SHELLS.includes(normalized)) { | ||||||||||||||||||||||||||||||||||||
| console.error(pc.red(`Unsupported shell: "${shell}". Supported shells: ${VALID_SHELLS.join(', ')}`)); | ||||||||||||||||||||||||||||||||||||
| process.exit(1); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| process.stdout.write(getCompletionScript(normalized)); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 MEDIUM RISK
Suggestion: The completion scripts are missing several short-form flags (e.g., -y, -v, -m, -n) and long-form aliases (e.g., --auto) defined in the CLI. Please synchronize the scripts with the definitions in
src/index.tsto ensure all valid options are suggested to the user.