Skip to content

Commit

Permalink
fix: Do not handle 3-levels nested subcommand.
Browse files Browse the repository at this point in the history
Nested subcommand more than 3 levels is not practical in public.
Take rustup for example, `rustup toolchain install <version>`,
there is only 3 levels of nested subcommands. But there is also
the case of `rustup help toolchain install`, or `rustup toolchain help install`.
  • Loading branch information
tesuji committed Jul 6, 2024
1 parent a6ac45f commit 1d94540
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions clap_complete/src/shells/fish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down

0 comments on commit 1d94540

Please sign in to comment.