Skip to content
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

fix(zsh): Separate options from _arguments options #5523

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading