Skip to content

Commit

Permalink
fix: Fix conditions to generate helpers
Browse files Browse the repository at this point in the history
Both should be met.
  • Loading branch information
tesuji committed Jul 6, 2024
1 parent 6c706d5 commit e276fc4
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions clap_complete/src/shells/fish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Generator for Fish {
let name = escape_name(bin_name);
let mut needs_fn_name = &format!("__fish_{name}_needs_command")[..];
let mut using_fn_name = &format!("__fish_{name}_using_subcommand")[..];
if has_global_flags {
if has_global_flags && cmd.has_subcommands() {
gen_subcommand_helpers(&name, cmd, buf, needs_fn_name, using_fn_name);
} else {
needs_fn_name = "__fish_use_subcommand";
Expand Down Expand Up @@ -215,9 +215,6 @@ fn gen_subcommand_helpers(
needs_fn_name: &str,
using_fn_name: &str,
) {
if !cmd.has_subcommands() {
return;
}
let mut optspecs = String::new();
let cmd_opts = cmd.get_arguments().filter(|a| !a.is_positional());
for option in cmd_opts {
Expand Down

0 comments on commit e276fc4

Please sign in to comment.