-
-
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
clap_generate: zsh broken with two multi length arguments #3022
Comments
Thanks for reporting this! One challenge with completions is we have to effectively re-implement clap's argument parsing for each shell we support. Example of other issues that look like they stem from this:
This is making me think that #1232 is even more important so we can share parsing logic between different shells and clap and more easily test it. |
To be more explicitly clear, it's not the parsing logic we need to share but rather the parsing requirements. |
The same issue arises with a more common pattern too (see https://github.com/drahnr/clap-completion-zoink/blob/84a3eb106309d066e80645f60a3065525d18c5a4 for a full working example):
On tab completion results in
|
`garden cmd <TAB>` generates an error on zsh: _arguments:comparguments:325: doubled rest argument definition: *::arguments -- Arguments to forward to custom commands: The root cause of the issue is that the generated completion script contains two `*::` entries in the `garden cmd` arguments: '*::commands -- Custom commands to run over the resolved trees:' \ '*::arguments -- Arguments to forward to custom commands:' \ A simple workaround is to drop the 2nd `*::arguments` entry. Use a `grep` filter to workaround the zsh completion bug from clap-rs/clap#3022 for now. Document the workaround and add link to the issue. Closes #10 Related-to: clap-rs/clap#3022 Signed-off-by: David Aguilar <[email protected]>
I believe #4612 may resolve this issue. I ran into this while creating https://github.com/davvid/garden so I figured we might as well fix it (rather than workaround it). Kindly test it out and let me know if it works for y'all as well. |
Have you not fully fixed this feature yet? The completion doesn't break now, but it also does nothing. Here are the Cargo.toml and the completion script: https://gist.github.com/TD-Sky/59eb28d92f8dae38129182e66da6b00c |
@TD-Sky I spent some minutes trying to compile your project and looking into what might be u. It doesn't look like the project you shared (conceal) compiles in the two branches I tried -- main and zsh-complete. If you have a working branch that that is made worse by these changes then please share the details. Feel free to take a look at how I'm setting up the subcommands but we probably shouldn't clutter this issue with too many project-specific details. Anyways, here's some working examples if you want to see them: This is the top-level parser: And this is where the sub-commands are defined: |
I have tried to compile with your patches in the local part of I have read the code your arguments parser. But you don't use |
Related-to: #10 Related-to: clap-rs/clap#3022 Related-to: clap-rs/clap#4624 Signed-off-by: David Aguilar <[email protected]>
Now that clap-rs/clap#4624 was merged we can use value_terminator to fix the zsh completions for commands that use two consecutive multi-valued arguments. A more complete solution may arrive in clap-rs/clap#4612 but until that is merged we can use this solution for now. If that change is ever merged then we can bump our clap_complete version and remove our use of value_terminator. Related-to: #10 Related-to: clap-rs/clap#3022 Related-to: clap-rs/clap#4624 Signed-off-by: David Aguilar <[email protected]>
Please complete the following tasks
Rust Version
rustc 1.58.0-nightly (8b09ba6a5 2021-11-09)
Clap Version
3.0.0-beta.5
Minimal reproducible code
Steps to reproduce the bug with the above code
With the completion installed:
Actual Behaviour
So I have a program that has a usage like this:
program: <targets>... -- <files>...
The zsh completion seems to really not like this and spits out an error when tab is hit:
_arguments:comparguments:325: doubled rest argument definition: *::file -- Files to search for:
The completion generated is:
Expected Behaviour
Don't be broken
Additional Context
No response
Debug Output
No response
The text was updated successfully, but these errors were encountered: