feat(complete): group options by tag (in zsh)#6334
Open
bobrippling wants to merge 2 commits intoclap-rs:masterfrom
Open
feat(complete): group options by tag (in zsh)#6334bobrippling wants to merge 2 commits intoclap-rs:masterfrom
zsh)#6334bobrippling wants to merge 2 commits intoclap-rs:masterfrom
Conversation
2 tasks
e5a4b4d to
629cac1
Compare
zsh)zsh)
65f0b45 to
b161c88
Compare
epage
reviewed
Apr 13, 2026
b161c88 to
0609ae5
Compare
2 tasks
zsh)zsh)
epage
reviewed
Apr 13, 2026
epage
reviewed
Apr 13, 2026
Comment on lines
388
to
+402
| if [[ "$value" == */ ]]; then | ||
| local dir_no_slash="${value%/}" | ||
| if [[ "$completion" == *:* ]]; then | ||
| local desc="${completion#*:}" | ||
| if [[ "$value" == *:* ]]; then | ||
| local desc="${value#*:}" | ||
| dirs+=("$dir_no_slash:$desc") | ||
| else | ||
| dirs+=("$dir_no_slash") | ||
| fi | ||
| else | ||
| other+=("$completion") | ||
| if (( ${+tag_map["$tag"]} )); then # key exists? | ||
| tag_map["$tag"]+=$'\n'"$value" | ||
| else | ||
| tag_map["$tag"]="$value" | ||
| fi | ||
| fi |
Member
There was a problem hiding this comment.
Does this mean we aren't getting the / handling if a tag is present?
Author
There was a problem hiding this comment.
The opposite in fact - if a / is there, we'll handle it (since we test that first) and only perform the option grouping for remaining options
Member
There was a problem hiding this comment.
Items with / should still have grouping though
epage
reviewed
Apr 13, 2026
| } | ||
| write!( | ||
| buf, | ||
| "{}:", |
Author
There was a problem hiding this comment.
I suppose we have two options:
- Pick a different separator - but what if that separator is in the tag?
- Avoid
:in tags, either by filtering them out at this point, or making it part of the tag requirement
What do you think?
Member
There was a problem hiding this comment.
We can pick an unlikely separator, like _SEP_
epage
reviewed
Apr 13, 2026
scutuatua-crypto
approved these changes
Apr 17, 2026
eb40761 to
eeee9ab
Compare
eeee9ab to
db855d8
Compare
db855d8 to
9e85b97
Compare
epage
reviewed
May 1, 2026
| % zstyle ':completion:*' group-name '' | ||
| % zstyle ':completion:*:descriptions' format '%d' | ||
| % exhaustive - | ||
| "Options" options |
Member
There was a problem hiding this comment.
This is redundant. In --help, we just list the header. We should likely do the same here as well.
epage
reviewed
May 1, 2026
Comment on lines
+451
to
+452
| "zstyle ':completion:*' group-name ''", | ||
| "zstyle ':completion:*:descriptions' format '%d'", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This allows zsh to group completions by whether they're global, and then by their tag. For example:
Closes #6320
Outstanding Questions
Options name
completing "Options" optionsdoesn't seem particulary nice, should we filter out the default"Options"tag?clap/clap_complete/src/engine/complete.rs
Lines 532 to 534 in 1420275
when generating the completions in
shells.rsTests
My new test is currently failing because it gets the zsh initial login setup:
I'm not sure why my test gets this but the others don't