-
-
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
Allow completion of partial commands [Powershell] #2750
Comments
Would welcome a PR, I don't have a powershell to help |
solution suggested by @benedictleejh here: clap-rs#2750
Based on solution suggested here by @benedictleejh: clap-rs#2750
@benedictleejh, I've created a btanch following your suggestion and it seems to work fine for me. It's created on top of clap [patch.crates-io]
clap = { git = "https://github.com/babysnakes/clap", branch = "powershell-fix" }
clap_complete = { git = "https://github.com/babysnakes/clap", branch = "powershell-fix" } If it works for you I'll implement it on top of master and create a PR. |
@babysnakes, I've managed to do a quick check, and it seems to work fine for me as well. Thanks for implementing this. |
Cool @benedictleejh, I'll apply it on top of master and create a PR. |
Based on solution suggested here by @benedictleejh: clap-rs#2750
@benedictleejh, there was a release today with the changes ( |
Please complete the following tasks
Clap Version
2.33.3
Describe your use case
Currently, the completion script generated by clap does not complete partial commands on Powershell (at least on 7.1.4). Examples are from Starship, which is where I encountered the problem.
No completions are returned when attempting to complete
starship i
in Powershell:But completions are returned when attempting to only complete
starship
:Investigating the completion code, it seems that the
$commandAst
contains the entire string of subcommands as currently entered, which results in the$command
generated being the stringstarship;i
for which there are no completions returned by the completion code, and hence no completions for Powershell to use.Describe the solution you'd like
The solution I've managed to put together is to exclude the current
$wordToComplete
from the generated$command
string, so that the completions for the correct command is being returned. I have only modified the generated completion code for my use, but the relevant code is found in clap/clap_generate/src/generators/shells/powershell.rs, lines 36-38:Changing the condition to:
allows the current word that needs completion to be excluded, and the completions for the correct command to be returned.
Alternatives, if applicable
No response
Additional Context
Starship's generated completion script is as follows:
The text was updated successfully, but these errors were encountered: