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(complete): Put clap in chage of Fish ordering #5722

Merged
merged 2 commits into from
Sep 4, 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/env/shells.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl EnvCompleter for Fish {

writeln!(
buf,
r#"complete -x -c {bin} -a "({var}=fish "'{completer}'" -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))""#
r#"complete --keep-order --exclusive --command {bin} --arguments "({var}=fish "'{completer}'" -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))""#
)
}
fn write_complete(
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
complete -x -c exhaustive -a "(COMPLETE=fish "'exhaustive'" -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))"
complete --keep-order --exclusive --command exhaustive --arguments "(COMPLETE=fish "'exhaustive'" -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))"
36 changes: 18 additions & 18 deletions clap_complete/tests/testsuite/fish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ fn complete_dynamic_env_toplevel() {

let input = "exhaustive \t\t";
let expected = snapbox::str![[r#"
% exhaustive action
action pacman --generate (generate)
alias quote --global (everywhere)
help (Print this message or the help of the given subcommand(s)) value --help (Print help)
hint -h (Print help) --version (Print version)
last -V (Print version)
% exhaustive --global
--global (everywhere) -V (Print version) last
--generate (generate) action pacman
--help (Print help) alias quote
--version (Print version) help (Print this message or the help of the given subcommand(s)) value
-h (Print help) hint
"#]];
let actual = runtime.complete(input, &term).unwrap();
assert_data_eq!(actual, expected);
Expand All @@ -215,6 +215,18 @@ fn complete_dynamic_env_quoted_help() {
let input = "exhaustive quote \t\t";
let expected = snapbox::str![[r#"
% exhaustive quote
--single-quotes (Can be 'always', 'auto', or 'never')
--double-quotes (Can be "always", "auto", or "never")
--backticks (For more information see `echo test`)
--backslash (Avoid '/n')
--brackets (List packages [filter])
--expansions (Execute the shell command with $SHELL)
--choice
--global (everywhere)
--help (Print help (see more with '--help'))
--version (Print version)
-h (Print help (see more with '--help'))
-V (Print version)
cmd-backslash (Avoid '/n')
cmd-backticks (For more information see `echo test`)
cmd-brackets (List packages [filter])
Expand All @@ -223,18 +235,6 @@ cmd-expansions (Execute the shell command with $SHELL)
cmd-single-quotes (Can be 'always', 'auto', or 'never')
escape-help (/tab "')
help (Print this message or the help of the given subcommand(s))
-h (Print help (see more with '--help'))
-V (Print version)
--backslash (Avoid '/n')
--backticks (For more information see `echo test`)
--brackets (List packages [filter])
--choice
--double-quotes (Can be "always", "auto", or "never")
--expansions (Execute the shell command with $SHELL)
--global (everywhere)
--help (Print help (see more with '--help'))
--single-quotes (Can be 'always', 'auto', or 'never')
--version (Print version)
"#]];
let actual = runtime.complete(input, &term).unwrap();
assert_data_eq!(actual, expected);
Expand Down
Loading