From 4f45406e686123073d231b8687881dea6930871f Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sat, 6 Jul 2024 17:45:12 +0000 Subject: [PATCH] fix: Is option? --- clap_complete/src/shells/fish.rs | 4 +++- .../static/exhaustive/fish/fish/completions/exhaustive.fish | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/clap_complete/src/shells/fish.rs b/clap_complete/src/shells/fish.rs index 65f49b73409..c1b419e2ac6 100644 --- a/clap_complete/src/shells/fish.rs +++ b/clap_complete/src/shells/fish.rs @@ -231,7 +231,9 @@ fn gen_subcommand_helpers( } optspecs.push_str(&escape_string(long, false)); } - if option.is_required_set() { + + let is_an_option = option.get_num_args().map(|r| r.takes_values()).unwrap_or(true); + if is_an_option { optspecs.push('='); } } diff --git a/clap_complete/tests/snapshots/home/static/exhaustive/fish/fish/completions/exhaustive.fish b/clap_complete/tests/snapshots/home/static/exhaustive/fish/fish/completions/exhaustive.fish index c5e0689aee7..a5bb92fbd11 100644 --- a/clap_complete/tests/snapshots/home/static/exhaustive/fish/fish/completions/exhaustive.fish +++ b/clap_complete/tests/snapshots/home/static/exhaustive/fish/fish/completions/exhaustive.fish @@ -1,6 +1,6 @@ # Print an optspec for argparse to handle cmd's options that are independent of any subcommand. function __fish_exhaustive_global_optspecs - string join \n global generate h/help V/version + string join \n global generate= h/help V/version end function __fish_exhaustive_needs_command