Skip to content

Commit

Permalink
doc: Explain why we fallback to the old behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji committed Jul 9, 2024
1 parent eba26a9 commit 0462be6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion clap_complete/src/shells/fish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ impl Generator for Fish {
.get_bin_name()
.expect("crate::generate should have set the bin_name");

// `-h` and `-v` behaves as command, not regular flags/options that modifies subcommand behaviors.
// If there is any regular flags, we may have complicated cases, e.g. `git --git-dir somedir status`. Using normal
// `__fish_seen_subcommand_from` won't help us find out the real subcommand is `status`, and not `somedir`.
// However, we prefer to fallback to the old behavior when there are no regular flags. `-h` and `-v` is not
// a regular flag and it behaves like a command. E.g., `rustup --version toolchain` is not a valid command line.
let has_global_flags = cmd.get_arguments().any(|a| {
!a.is_positional() && !matches!(a.get_action(), Help | HelpShort | HelpLong | Version)
});
Expand Down

0 comments on commit 0462be6

Please sign in to comment.