Skip to content

Commit 6ec0b43

Browse files
authored
Merge pull request #5791 from okapia/zsh-default-fallback
fix(zsh): Use _default as the completion fallback where the ValueHint is Unknown
2 parents 55a18f5 + e40168c commit 6ec0b43

File tree

10 files changed

+31
-33
lines changed

10 files changed

+31
-33
lines changed

clap_complete/src/aot/shells/zsh.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,8 @@ fn value_completion(arg: &Arg) -> Option<String> {
396396
// NB! If you change this, please also update the table in `ValueHint` documentation.
397397
Some(
398398
match arg.get_value_hint() {
399-
ValueHint::Unknown => {
400-
return None;
401-
}
402-
ValueHint::Other => "( )",
399+
ValueHint::Unknown => "_default",
400+
ValueHint::Other => "",
403401
ValueHint::AnyPath => "_files",
404402
ValueHint::FilePath => "_files",
405403
ValueHint::DirPath => "_files -/",

clap_complete/tests/snapshots/aliases.zsh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ _my-app() {
1515

1616
local context curcontext="$curcontext" state line
1717
_arguments "${_arguments_options[@]}" : \
18-
'-o+[cmd option]: : ' \
19-
'-O+[cmd option]: : ' \
20-
'--option=[cmd option]: : ' \
21-
'--opt=[cmd option]: : ' \
18+
'-o+[cmd option]: :_default' \
19+
'-O+[cmd option]: :_default' \
20+
'--option=[cmd option]: :_default' \
21+
'--opt=[cmd option]: :_default' \
2222
'-f[cmd flag]' \
2323
'-F[cmd flag]' \
2424
'--flag[cmd flag]' \
@@ -27,7 +27,7 @@ _my-app() {
2727
'--help[Print help]' \
2828
'-V[Print version]' \
2929
'--version[Print version]' \
30-
'::positional:' \
30+
'::positional:_default' \
3131
&& ret=0
3232
}
3333

clap_complete/tests/snapshots/feature_sample.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _my-app() {
3636
case $line[3] in
3737
(test)
3838
_arguments "${_arguments_options[@]}" : \
39-
'--case=[the case to test]: : ' \
39+
'--case=[the case to test]: :_default' \
4040
'-h[Print help]' \
4141
'--help[Print help]' \
4242
'-V[Print version]' \

clap_complete/tests/snapshots/home/static/exhaustive/zsh/zsh/_exhaustive

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ _exhaustive() {
3232
case $line[1] in
3333
(action)
3434
_arguments "${_arguments_options[@]}" : \
35-
'--set=[value]: : ' \
35+
'--set=[value]: :_default' \
3636
'--choice=[enum]: :(first second)' \
3737
'--set-true[bool]' \
3838
'*--count[number]' \
@@ -187,15 +187,15 @@ esac
187187
;;
188188
(value)
189189
_arguments "${_arguments_options[@]}" : \
190-
'--delim=[]: : ' \
191-
'--tuple=[]: : : : ' \
192-
'--require-eq=[]: : ' \
190+
'--delim=[]: :_default' \
191+
'--tuple=[]: :_default: :_default' \
192+
'--require-eq=[]: :_default' \
193193
'--global[everywhere]' \
194194
'-h[Print help]' \
195195
'--help[Print help]' \
196196
'-V[Print version]' \
197197
'--version[Print version]' \
198-
'*;::term:' \
198+
'*;::term:_default' \
199199
&& ret=0
200200
;;
201201
(pacman)
@@ -272,16 +272,16 @@ _arguments "${_arguments_options[@]}" : \
272272
'--help[Print help]' \
273273
'-V[Print version]' \
274274
'--version[Print version]' \
275-
'::first:' \
276-
'::free:' \
275+
'::first:_default' \
276+
'::free:_default' \
277277
&& ret=0
278278
;;
279279
(alias)
280280
_arguments "${_arguments_options[@]}" : \
281-
'-o+[cmd option]: : ' \
282-
'-O+[cmd option]: : ' \
283-
'--option=[cmd option]: : ' \
284-
'--opt=[cmd option]: : ' \
281+
'-o+[cmd option]: :_default' \
282+
'-O+[cmd option]: :_default' \
283+
'--option=[cmd option]: :_default' \
284+
'--opt=[cmd option]: :_default' \
285285
'-f[cmd flag]' \
286286
'-F[cmd flag]' \
287287
'--flag[cmd flag]' \
@@ -291,14 +291,14 @@ _arguments "${_arguments_options[@]}" : \
291291
'--help[Print help]' \
292292
'-V[Print version]' \
293293
'--version[Print version]' \
294-
'::positional:' \
294+
'::positional:_default' \
295295
&& ret=0
296296
;;
297297
(hint)
298298
_arguments "${_arguments_options[@]}" : \
299299
'--choice=[]: :(bash fish zsh)' \
300-
'--unknown=[]: : ' \
301-
'--other=[]: :( )' \
300+
'--unknown=[]: :_default' \
301+
'--other=[]: :' \
302302
'-p+[]: :_files' \
303303
'--path=[]: :_files' \
304304
'-f+[]: :_files' \

clap_complete/tests/snapshots/special_commands.zsh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _my-app() {
3636
case $line[3] in
3737
(test)
3838
_arguments "${_arguments_options[@]}" : \
39-
'--case=[the case to test]: : ' \
39+
'--case=[the case to test]: :_default' \
4040
'-h[Print help]' \
4141
'--help[Print help]' \
4242
'-V[Print version]' \
@@ -45,12 +45,12 @@ _arguments "${_arguments_options[@]}" : \
4545
;;
4646
(some_cmd)
4747
_arguments "${_arguments_options[@]}" : \
48-
'--config=[the other case to test]: : ' \
48+
'--config=[the other case to test]: :_default' \
4949
'-h[Print help]' \
5050
'--help[Print help]' \
5151
'-V[Print version]' \
5252
'--version[Print version]' \
53-
'*::path:' \
53+
'*::path:_default' \
5454
&& ret=0
5555
;;
5656
(some-cmd-with-hyphens)

clap_complete/tests/snapshots/sub_subcommands.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _my-app() {
3636
case $line[3] in
3737
(test)
3838
_arguments "${_arguments_options[@]}" : \
39-
'--case=[the case to test]: : ' \
39+
'--case=[the case to test]: :_default' \
4040
'-h[Print help]' \
4141
'--help[Print help]' \
4242
'-V[Print version]' \

clap_complete/tests/snapshots/subcommand_last.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ _my-app() {
1717
_arguments "${_arguments_options[@]}" : \
1818
'-h[Print help]' \
1919
'--help[Print help]' \
20-
'::free:' \
20+
'::free:_default' \
2121
":: :_my-app_commands" \
2222
"*::: :->my-app" \
2323
&& ret=0

clap_complete/tests/snapshots/two_multi_valued_arguments.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ _my-app() {
1717
_arguments "${_arguments_options[@]}" : \
1818
'-h[Print help]' \
1919
'--help[Print help]' \
20-
'*::first -- first multi-valued argument:' \
20+
'*::first -- first multi-valued argument:_default' \
2121
&& ret=0
2222
}
2323

clap_complete/tests/snapshots/value_hint.zsh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ _my-app() {
1616
local context curcontext="$curcontext" state line
1717
_arguments "${_arguments_options[@]}" : \
1818
'--choice=[]: :(bash fish zsh)' \
19-
'--unknown=[]: : ' \
20-
'--other=[]: :( )' \
19+
'--unknown=[]: :_default' \
20+
'--other=[]: :' \
2121
'-p+[]: :_files' \
2222
'--path=[]: :_files' \
2323
'-f+[]: :_files' \

clap_complete/tests/snapshots/value_terminator.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ _my-app() {
1717
_arguments "${_arguments_options[@]}" : \
1818
'-h[Print help]' \
1919
'--help[Print help]' \
20-
'*;::arguments -- multi-valued argument with a value terminator:' \
20+
'*;::arguments -- multi-valued argument with a value terminator:_default' \
2121
&& ret=0
2222
}
2323

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy