-
-
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
Custom value hint #2396
Comments
Duplicate of #1232 I assume you saw that issue when searching? Why did you decide to create a new one? |
No I didn't see that. Sorry. |
#1232 seems to be about delegating completion to clap itself. By extending |
Since the design for #1232 is not yet done and the thing being requested here is so close what's being discussed in that issue, they might actually end up being the same. |
Please complete the following tasks
Describe your use case
Let's imagine I have a
make
-like utility. And I want:To complete to commands listed in the
Makefile
in the current directory. Most current shells can handle this, but I don't think there is a way to generate completions for that by clap.Describe the solution you'd like
I propose something like this:
This means that shell runs
$binname --list-targets
to fetch the names of the targets for completion.The complication is that some shells (namely zsh) may use a description in completion data but others can't so there are two options:
--shell=zsh
for command (this is nice if command has subcommands:mymake list-targets --shell=zsh
but is weird ifmymake --list-targets --shell=zsh
, because basically--shell=
will be accepted but not used in any invocation)Alternatives, if applicable
Alternative solution is to have
ValueHint::ShellFunction("_my_make_targets")
and manually append function_my_make_targets
to the generated file. This is more flexible, but is harder to use since the shell function will have to be implemented for every shell manually.What do you think?
The text was updated successfully, but these errors were encountered: