From 2167fee212b96999c5d30757f837afb48d9bea3e Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sat, 6 Jul 2024 07:58:43 +0700 Subject: [PATCH] fix(fish): Don't handle level 3 nested subcommand Nested subcommand more than 3 levels is not practical in public. Take rustup for example, `rustup toolchain install `, there is only 3 levels of nested subcommands. But there is also the case of `rustup help toolchain install`, or `rustup toolchain help install`. --- clap_complete/src/shells/fish.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/clap_complete/src/shells/fish.rs b/clap_complete/src/shells/fish.rs index 087be3ea821..5f1ddae6a3b 100644 --- a/clap_complete/src/shells/fish.rs +++ b/clap_complete/src/shells/fish.rs @@ -121,15 +121,9 @@ fn gen_fish_inner( [command, subcommand] => out.push_str(&format!( " {command}; and __fish_seen_subcommand_from {subcommand}" )), - [command, "help", _subcommand] => { - out.push_str(&format!(" {command}; and __fish_seen_subcommand_from help")); - } - ["help", command, _subcommand] => { - out.push_str(&format!(" help; and __fish_seen_subcommand_from {command}")); - } - _ => unimplemented!( - "subcommand should be nested less than 3 levels: {parent_commands:?}" - ), + // Subcommand should be nested less than 3 levels to be practical + // `rustup toolchain help install` cannot receive any flags to it. + _ => return, } basic_template.push_str(format!(" -n \"{out}\"").as_str()); }