Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't panic when propagating #3311

Merged
merged 1 commit into from Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/build/app/mod.rs
Expand Up @@ -2932,7 +2932,7 @@ impl<'help> App<'help> {
help_subcmd.long_version = None;
help_subcmd = help_subcmd
.setting(AppSettings::DisableHelpFlag)
.unset_setting(AppSettings::PropagateVersion);
.unset_global_setting(AppSettings::PropagateVersion);

self.subcommands.push(help_subcmd);
}
Expand Down
25 changes: 25 additions & 0 deletions tests/builder/help.rs
Expand Up @@ -2734,3 +2734,28 @@ fn disable_help_flag_affects_help_subcommand() {
args
);
}

#[test]
fn dont_propagate_version_to_help_subcommand() {
let app = clap::App::new("test")
.version("1.0")
.global_setting(clap::AppSettings::PropagateVersion)
.subcommand(clap::App::new("subcommand"));

assert!(utils::compare_output(
app.clone(),
"example help help",
"example-help
Print this message or the help of the given subcommand(s)

USAGE:
example help [SUBCOMMAND]...

ARGS:
<SUBCOMMAND>... The subcommand whose help message to display
",
false
));

app.debug_assert();
}