Skip to content

Commit 8e3c273

Browse files
committed
fix(zsh): Separate options from _arguments options
1 parent ff3713d commit 8e3c273

13 files changed

+120
-120
lines changed

clap_complete/src/shells/zsh.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ fn parser_of<'cmd>(parent: &'cmd Command, bin_name: &str) -> Option<&'cmd Comman
322322
fn get_args_of(parent: &Command, p_global: Option<&Command>) -> String {
323323
debug!("get_args_of");
324324

325-
let mut segments = vec![String::from("_arguments \"${_arguments_options[@]}\" \\")];
325+
let mut segments = vec![String::from("_arguments \"${_arguments_options[@]}\" : \\")];
326326
let opts = write_opts_of(parent, p_global);
327327
let flags = write_flags_of(parent, p_global);
328328
let positionals = write_positionals_of(parent);

clap_complete/tests/snapshots/aliases.zsh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ _my-app() {
1414
fi
1515

1616
local context curcontext="$curcontext" state line
17-
_arguments "${_arguments_options[@]}" \
17+
_arguments "${_arguments_options[@]}" : \
1818
'-o+[cmd option]: : ' \
1919
'-O+[cmd option]: : ' \
2020
'--option=[cmd option]: : ' \

clap_complete/tests/snapshots/basic.zsh

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ _my-app() {
1414
fi
1515

1616
local context curcontext="$curcontext" state line
17-
_arguments "${_arguments_options[@]}" \
17+
_arguments "${_arguments_options[@]}" : \
1818
'-c[]' \
1919
'(-c)-v[]' \
2020
'-h[Print help]' \
@@ -29,15 +29,15 @@ _my-app() {
2929
curcontext="${curcontext%:*:*}:my-app-command-$line[1]:"
3030
case $line[1] in
3131
(test)
32-
_arguments "${_arguments_options[@]}" \
32+
_arguments "${_arguments_options[@]}" : \
3333
'*-d[]' \
3434
'-c[]' \
3535
'-h[Print help]' \
3636
'--help[Print help]' \
3737
&& ret=0
3838
;;
3939
(help)
40-
_arguments "${_arguments_options[@]}" \
40+
_arguments "${_arguments_options[@]}" : \
4141
":: :_my-app__help_commands" \
4242
"*::: :->help" \
4343
&& ret=0
@@ -49,11 +49,11 @@ _arguments "${_arguments_options[@]}" \
4949
curcontext="${curcontext%:*:*}:my-app-help-command-$line[1]:"
5050
case $line[1] in
5151
(test)
52-
_arguments "${_arguments_options[@]}" \
52+
_arguments "${_arguments_options[@]}" : \
5353
&& ret=0
5454
;;
5555
(help)
56-
_arguments "${_arguments_options[@]}" \
56+
_arguments "${_arguments_options[@]}" : \
5757
&& ret=0
5858
;;
5959
esac

clap_complete/tests/snapshots/custom_bin_name.zsh

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ _bin-name() {
1414
fi
1515

1616
local context curcontext="$curcontext" state line
17-
_arguments "${_arguments_options[@]}" \
17+
_arguments "${_arguments_options[@]}" : \
1818
'-c[]' \
1919
'(-c)-v[]' \
2020
'-h[Print help]' \
@@ -29,15 +29,15 @@ _bin-name() {
2929
curcontext="${curcontext%:*:*}:bin-name-command-$line[1]:"
3030
case $line[1] in
3131
(test)
32-
_arguments "${_arguments_options[@]}" \
32+
_arguments "${_arguments_options[@]}" : \
3333
'*-d[]' \
3434
'-c[]' \
3535
'-h[Print help]' \
3636
'--help[Print help]' \
3737
&& ret=0
3838
;;
3939
(help)
40-
_arguments "${_arguments_options[@]}" \
40+
_arguments "${_arguments_options[@]}" : \
4141
":: :_bin-name__help_commands" \
4242
"*::: :->help" \
4343
&& ret=0
@@ -49,11 +49,11 @@ _arguments "${_arguments_options[@]}" \
4949
curcontext="${curcontext%:*:*}:bin-name-help-command-$line[1]:"
5050
case $line[1] in
5151
(test)
52-
_arguments "${_arguments_options[@]}" \
52+
_arguments "${_arguments_options[@]}" : \
5353
&& ret=0
5454
;;
5555
(help)
56-
_arguments "${_arguments_options[@]}" \
56+
_arguments "${_arguments_options[@]}" : \
5757
&& ret=0
5858
;;
5959
esac

clap_complete/tests/snapshots/feature_sample.zsh

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ _my-app() {
1414
fi
1515

1616
local context curcontext="$curcontext" state line
17-
_arguments "${_arguments_options[@]}" \
17+
_arguments "${_arguments_options[@]}" : \
1818
'*-c[some config file]' \
1919
'*-C[some config file]' \
2020
'*--config[some config file]' \
@@ -35,7 +35,7 @@ _my-app() {
3535
curcontext="${curcontext%:*:*}:my-app-command-$line[3]:"
3636
case $line[3] in
3737
(test)
38-
_arguments "${_arguments_options[@]}" \
38+
_arguments "${_arguments_options[@]}" : \
3939
'--case=[the case to test]: : ' \
4040
'-h[Print help]' \
4141
'--help[Print help]' \
@@ -44,7 +44,7 @@ _arguments "${_arguments_options[@]}" \
4444
&& ret=0
4545
;;
4646
(help)
47-
_arguments "${_arguments_options[@]}" \
47+
_arguments "${_arguments_options[@]}" : \
4848
":: :_my-app__help_commands" \
4949
"*::: :->help" \
5050
&& ret=0
@@ -56,11 +56,11 @@ _arguments "${_arguments_options[@]}" \
5656
curcontext="${curcontext%:*:*}:my-app-help-command-$line[1]:"
5757
case $line[1] in
5858
(test)
59-
_arguments "${_arguments_options[@]}" \
59+
_arguments "${_arguments_options[@]}" : \
6060
&& ret=0
6161
;;
6262
(help)
63-
_arguments "${_arguments_options[@]}" \
63+
_arguments "${_arguments_options[@]}" : \
6464
&& ret=0
6565
;;
6666
esac

0 commit comments

Comments
 (0)