Skip to content

Commit

Permalink
fix(zsh): Separate options from _arguments options
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-- committed Jun 7, 2024
1 parent ff3713d commit 8e3c273
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 120 deletions.
2 changes: 1 addition & 1 deletion clap_complete/src/shells/zsh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ fn parser_of<'cmd>(parent: &'cmd Command, bin_name: &str) -> Option<&'cmd Comman
fn get_args_of(parent: &Command, p_global: Option<&Command>) -> String {
debug!("get_args_of");

let mut segments = vec![String::from("_arguments \"${_arguments_options[@]}\" \\")];
let mut segments = vec![String::from("_arguments \"${_arguments_options[@]}\" : \\")];
let opts = write_opts_of(parent, p_global);
let flags = write_flags_of(parent, p_global);
let positionals = write_positionals_of(parent);
Expand Down
2 changes: 1 addition & 1 deletion clap_complete/tests/snapshots/aliases.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _my-app() {
fi

local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" \
_arguments "${_arguments_options[@]}" : \
'-o+[cmd option]: : ' \
'-O+[cmd option]: : ' \
'--option=[cmd option]: : ' \
Expand Down
10 changes: 5 additions & 5 deletions clap_complete/tests/snapshots/basic.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _my-app() {
fi

local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" \
_arguments "${_arguments_options[@]}" : \
'-c[]' \
'(-c)-v[]' \
'-h[Print help]' \
Expand All @@ -29,15 +29,15 @@ _my-app() {
curcontext="${curcontext%:*:*}:my-app-command-$line[1]:"
case $line[1] in
(test)
_arguments "${_arguments_options[@]}" \
_arguments "${_arguments_options[@]}" : \
'*-d[]' \
'-c[]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
_arguments "${_arguments_options[@]}" : \
":: :_my-app__help_commands" \
"*::: :->help" \
&& ret=0
Expand All @@ -49,11 +49,11 @@ _arguments "${_arguments_options[@]}" \
curcontext="${curcontext%:*:*}:my-app-help-command-$line[1]:"
case $line[1] in
(test)
_arguments "${_arguments_options[@]}" \
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
esac
Expand Down
10 changes: 5 additions & 5 deletions clap_complete/tests/snapshots/custom_bin_name.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _bin-name() {
fi

local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" \
_arguments "${_arguments_options[@]}" : \
'-c[]' \
'(-c)-v[]' \
'-h[Print help]' \
Expand All @@ -29,15 +29,15 @@ _bin-name() {
curcontext="${curcontext%:*:*}:bin-name-command-$line[1]:"
case $line[1] in
(test)
_arguments "${_arguments_options[@]}" \
_arguments "${_arguments_options[@]}" : \
'*-d[]' \
'-c[]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
_arguments "${_arguments_options[@]}" : \
":: :_bin-name__help_commands" \
"*::: :->help" \
&& ret=0
Expand All @@ -49,11 +49,11 @@ _arguments "${_arguments_options[@]}" \
curcontext="${curcontext%:*:*}:bin-name-help-command-$line[1]:"
case $line[1] in
(test)
_arguments "${_arguments_options[@]}" \
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
esac
Expand Down
10 changes: 5 additions & 5 deletions clap_complete/tests/snapshots/feature_sample.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _my-app() {
fi

local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" \
_arguments "${_arguments_options[@]}" : \
'*-c[some config file]' \
'*-C[some config file]' \
'*--config[some config file]' \
Expand All @@ -35,7 +35,7 @@ _my-app() {
curcontext="${curcontext%:*:*}:my-app-command-$line[3]:"
case $line[3] in
(test)
_arguments "${_arguments_options[@]}" \
_arguments "${_arguments_options[@]}" : \
'--case=[the case to test]: : ' \
'-h[Print help]' \
'--help[Print help]' \
Expand All @@ -44,7 +44,7 @@ _arguments "${_arguments_options[@]}" \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
_arguments "${_arguments_options[@]}" : \
":: :_my-app__help_commands" \
"*::: :->help" \
&& ret=0
Expand All @@ -56,11 +56,11 @@ _arguments "${_arguments_options[@]}" \
curcontext="${curcontext%:*:*}:my-app-help-command-$line[1]:"
case $line[1] in
(test)
_arguments "${_arguments_options[@]}" \
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
esac
Expand Down
Loading

0 comments on commit 8e3c273

Please sign in to comment.