From 059db0c1394a904cc83bed3cac2d9c5d6cef7bb0 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 4 Sep 2024 14:26:44 -0500 Subject: [PATCH 1/2] docs(complete): Clarify what flags we're using --- clap_complete/src/env/shells.rs | 2 +- .../exhaustive/fish/fish/completions/exhaustive.fish | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clap_complete/src/env/shells.rs b/clap_complete/src/env/shells.rs index 2c527d94dff..2d177168214 100644 --- a/clap_complete/src/env/shells.rs +++ b/clap_complete/src/env/shells.rs @@ -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 --exclusive --command {bin} --arguments "({var}=fish "'{completer}'" -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))""# ) } fn write_complete( diff --git a/clap_complete/tests/snapshots/home/dynamic-env/exhaustive/fish/fish/completions/exhaustive.fish b/clap_complete/tests/snapshots/home/dynamic-env/exhaustive/fish/fish/completions/exhaustive.fish index 0aae8215946..b36cb34a99d 100644 --- a/clap_complete/tests/snapshots/home/dynamic-env/exhaustive/fish/fish/completions/exhaustive.fish +++ b/clap_complete/tests/snapshots/home/dynamic-env/exhaustive/fish/fish/completions/exhaustive.fish @@ -1 +1 @@ -complete -x -c exhaustive -a "(COMPLETE=fish "'exhaustive'" -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))" +complete --exclusive --command exhaustive --arguments "(COMPLETE=fish "'exhaustive'" -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))" From e2d336b95f9370132d9ae638112d31be68ad9904 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 4 Sep 2024 14:28:03 -0500 Subject: [PATCH 2/2] fix(complete): Put clap in chage of Fish ordering --- clap_complete/src/env/shells.rs | 2 +- .../fish/fish/completions/exhaustive.fish | 2 +- clap_complete/tests/testsuite/fish.rs | 36 +++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/clap_complete/src/env/shells.rs b/clap_complete/src/env/shells.rs index 2d177168214..eb2cb10a080 100644 --- a/clap_complete/src/env/shells.rs +++ b/clap_complete/src/env/shells.rs @@ -226,7 +226,7 @@ impl EnvCompleter for Fish { writeln!( buf, - r#"complete --exclusive --command {bin} --arguments "({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( diff --git a/clap_complete/tests/snapshots/home/dynamic-env/exhaustive/fish/fish/completions/exhaustive.fish b/clap_complete/tests/snapshots/home/dynamic-env/exhaustive/fish/fish/completions/exhaustive.fish index b36cb34a99d..bd534ef312a 100644 --- a/clap_complete/tests/snapshots/home/dynamic-env/exhaustive/fish/fish/completions/exhaustive.fish +++ b/clap_complete/tests/snapshots/home/dynamic-env/exhaustive/fish/fish/completions/exhaustive.fish @@ -1 +1 @@ -complete --exclusive --command exhaustive --arguments "(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))" diff --git a/clap_complete/tests/testsuite/fish.rs b/clap_complete/tests/testsuite/fish.rs index f2ddf4e55b4..82498ff8cd5 100644 --- a/clap_complete/tests/testsuite/fish.rs +++ b/clap_complete/tests/testsuite/fish.rs @@ -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); @@ -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]) @@ -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);