-
-
Notifications
You must be signed in to change notification settings - Fork 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_complete: fix support for two multi-length arguments in zsh #4612
Conversation
b8fab94
to
a686e61
Compare
448865a
to
3123e33
Compare
I rebased a bunch of times and that may have caused this note to have gotten lost:
I also saw a note about using I'm going to keep the single-arg test and add an additional test with two args. I'm also going to adjust the logic so that the penultimate argument is special-cased. I'm going to make it the penultimate multi-value argument automatically inject a value terminator, either user-defined or the special default I think that should handle the edge cases around two multi-valued arguments. Existing code should pickup this fix without needing to add any annotations, etc. Thanks again for your reviews. I'll be pushing final updates into this PR shortly. |
f56b2c1
to
9ce49bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first two commits seem ready but I feel there is more to work out in the last. If you are wanting the first fix earlier, we can split this into two PRs and merge the value_terminator
work now.
Thanks for the sug to split this PR in two. The initial two commits are now in #4624 while we figure out what to do with the more complicated edge cases. |
9ce49bb
to
3bcbaee
Compare
zsh completions for commands that have multiple Vec arguments require special care. We can have two Vec args separated with a value terminator. We can also have two Vec args with no value terminators specified where the final arg uses 'raw' and thus requires '--' to be used. The 2nd of these scenarios requires special handling to avoid emitting a duplicate '*:arguments' completion entry. Currently, the zsh completions generate an error in this scenario: $ my-app <TAB> _arguments:...: doubled rest argument definition: *::second -- second set of of multi-length arguments: We already use the '-S' option when calling _arguments. This option makes it so that completion stops after '--' is encountered. This means that the handling for trailing 'raw' arguments does not need to specified. Special-case multi-valued arguments so that we can skip emitting the final multi-valued argument if a previous multi-valued argument has already been emitted. Closes clap-rs#3022 Signed-off-by: David Aguilar <davvid@gmail.com>
3bcbaee
to
170bd59
Compare
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 <davvid@gmail.com>
Related-to: #10 Signed-off-by: David Aguilar <davvid@gmail.com>
Great work here. How close is this to completion? |
Sorry, I had gotten busy with another project and I'm now getting a chance to go through my backlog. I suspect there are still corner cases but this is a case where some improvement is better than no improvement, so I'll go ahead and merge. |
Properly handle two consecutive multi-valued arguments.
Currently the zsh completion generates an error:
Special-case multi-valued arguments to avoid emitting duplicate catch-all arguments.
Closes #3022
Signed-off-by: David Aguilar davvid@gmail.com