-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Switch native completions to encourage env var initialization #3930
Labels
A-completion
Area: completion generator
A-docs
Area: documentation, including docs.rs, readme, examples, etc...
C-enhancement
Category: Raise on the bar on expectations
E-easy
Call for participation: Experience needed to fix: Easy / not much
Comments
epage
added
C-enhancement
Category: Raise on the bar on expectations
A-docs
Area: documentation, including docs.rs, readme, examples, etc...
A-completion
Area: completion generator
E-easy
Call for participation: Experience needed to fix: Easy / not much
labels
Jul 13, 2022
We now offer a subcommand for rust-native completions. Closing in favor of that. Stabilizing this is tracked in #3166 |
As we are no longer documenting but providing a solution, I'm going to repurpose this to change native completions to use the env variable approach
What we could do is offer both approaches, each behind a feature. Steps
|
epage
changed the title
Document different options for activating completions
Switch native completions to encourage env var initialization
Aug 10, 2024
22 tasks
epage
added a commit
to epage/clap
that referenced
this issue
Aug 12, 2024
epage
added a commit
to epage/clap
that referenced
this issue
Aug 12, 2024
epage
added a commit
to epage/clap
that referenced
this issue
Aug 12, 2024
epage
added a commit
to epage/clap
that referenced
this issue
Aug 12, 2024
epage
added a commit
to epage/clap
that referenced
this issue
Aug 12, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-completion
Area: completion generator
A-docs
Area: documentation, including docs.rs, readme, examples, etc...
C-enhancement
Category: Raise on the bar on expectations
E-easy
Call for participation: Experience needed to fix: Easy / not much
Maintainer's notes
We should document each solution (flag, subcommand, env var) and the trade offs. We should probably make env variable the default.
Discussed in #3926
Originally posted by AndreasBackx July 13, 2022
We have a nice macro that automatically adds autocomplete to your Clap CLI. We are currently doing this via a subcommand
generate-completions
. Though we realise that this approach makes it impossible to automatically generate completions for certain CLIs:Imagine we have that very simple CLI and we want to add a subcommand.
foo
is a required argument so if we want to automate the autocomplete generation by addingeval $(cli generate-completions)
or by exporting it to/usr/share/bash-completion/completions/cli
for Bash, the CLI will complain thatfoo
wasn't passed.Therefore it seems right now that we should avoid depending on Clap parsing as part of autocomplete generation. Perhaps the people at Click realised this earlier as that is what they are doing: https://click.palletsprojects.com/en/8.1.x/shell-completion/.
So I have a few questions that spring from this:
Funnily enough we didn't initially face this problem because of how
command_for_update
sets required to false, see #3924.The text was updated successfully, but these errors were encountered: