Repository navigation
feat(cli): add cook completions <shell> for shell completion scripts - #483
Merged
Merged
Conversation
Prints a completion script for bash, zsh, fish, PowerShell or elvish to
stdout, generated with clap_complete from the live `CliArgs` definition.
The script therefore matches the binary that produced it, including any
subcommands compiled out by cargo features.
The binary name is passed explicitly: clap's command name is the package
name ("cookcli"), and a script registered under that would never fire
for the `cook` users actually type.
Closes #467
Claude-Session: https://claude.ai/code/session_013cPWotrjEY4Jac87e6vHsh
ReviewClean, well-scoped addition — nice attention to detail catching the Code quality
Potential bugs
Performance
Security
Test coverage
Nothing blocking here — this looks ready to merge as-is. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #467
What
New
cook completions <shell>subcommand that prints a completion script forbash,zsh,fish,powershellorelvishto stdout, generated withclap_completefrom the existingCliArgsdefinition.src/completions.rswithCompletionsArgs { shell: clap_complete::Shell }andrun()Command::Completionsvariant plus match arm inmain.rsdocs/completions.mdwith per-shell install instructions, linked fromdocs/README.mdandREADME.mdtests/completions_test.rscovering every shell, subcommand/alias/flag coverage, and error casesWorth knowing
The binary name is passed explicitly rather than taken from
cmd.get_name(). That returns the package namecookcli, so the first cut registeredcomplete -F _cookcli cookcliand would never have fired forcook. The tests now assert on the exact registration line so a prefix match can't hide this again.Generated bash and zsh scripts parse cleanly under
bash -n/zsh -n. The help snapshot gained one line for the new subcommand.Open questions from the issue, and what this PR does about them
docs/completions.mdrather than worked around. The script matches whichever binary generated it.https://claude.ai/code/session_013cPWotrjEY4Jac87e6vHsh