-
-
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
Caller-defined complete
subcommand for rust-native completions
#5293
Comments
To clarify, you are wanting to replace the That isn't too clear from the proposed solution as its unclear what
dynamic completions are also very early in their development so I also generally recommend people use static completions at this time but I encourage fixes and improvements on dynamic completions. |
Yes
In /// Generally used via [`CompleteCommand`]
#[derive(clap::Args)]
#[command(arg_required_else_help = true)]
#[command(group = clap::ArgGroup::new("complete").multiple(true).conflicts_with("register"))]
#[allow(missing_docs)]
#[derive(Clone, Debug)]
pub struct CompleteArgs {
/// Specify shell to complete for
#[arg(long)]
shell: Shell,
/// Path to write completion-registration to
#[arg(long, required = true)]
register: Option<std::path::PathBuf>,
#[arg(raw = true, hide_short_help = true, group = "complete")]
comp_words: Vec<OsString>,
} So I think adding a function in
The dynamic completions could |
Its not clear to me why someone would want to use this struct but override Are you trying to use
It sounds like the concern is with compatibility being broken with how you currently do completions? I can understand that. However, the current built-in interface isn't stable yet either. Its also likely that you could make a generate parameter used for static completions that will then work for dynamic completions. The shell support might be a little different but you can choose now for a subset of shells (fig is one that I know won't work with dynamic completions). |
It's just my guess. Not the way you should follow. And looks like I didn't read the code correctly. You can choose the best way to implement this feature.
I use the way like dynamic example does.
Yes, I tried the static way. What I am concerned about is that the So I like the idea that dynamic completion hides the |
OK, I just saw that I can use the |
Overall, anyone is able to define their own |
Indeed. |
complete
subcommand for rust-native completions
In #5671, we added a new way to control the running of completions through environment variables. Due to the benefits mentioned in that issue, I'm inclined to have that be our "primary" way of doing things. It includes being able to customize the environment variable. For those that want a subcommand and want to customize it, I lean towards saying people should copy/paste the subcommand we provide. |
Please complete the following tasks
Clap Version
4.4.11
Describe your use case
Currently, the dynamic completion hides the parameter from the program's parameters and only shows with
$ cmd complete -h
, which is good. But it hard-codes the parameter withcomplete
, which may conflict with or be similar to the program's existing parameter. This makes$ cmd c
not work. It would be good if the user could define the complete parameter themself.Describe the solution you'd like
Maybe add a new function
fn set_comp_words
inimpl CompleteCommand
. Then we can define thecomp_words
ourself.Alternatives, if applicable
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: