Skip to content

Commit c6b5f64

Browse files
authored
Merge pull request #3311 from epage/fix
fix: Don't panic when propagating
2 parents 4b60440 + 38e6952 commit c6b5f64

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/build/app/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2932,7 +2932,7 @@ impl<'help> App<'help> {
29322932
help_subcmd.long_version = None;
29332933
help_subcmd = help_subcmd
29342934
.setting(AppSettings::DisableHelpFlag)
2935-
.unset_setting(AppSettings::PropagateVersion);
2935+
.unset_global_setting(AppSettings::PropagateVersion);
29362936

29372937
self.subcommands.push(help_subcmd);
29382938
}

tests/builder/help.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2734,3 +2734,28 @@ fn disable_help_flag_affects_help_subcommand() {
27342734
args
27352735
);
27362736
}
2737+
2738+
#[test]
2739+
fn dont_propagate_version_to_help_subcommand() {
2740+
let app = clap::App::new("test")
2741+
.version("1.0")
2742+
.global_setting(clap::AppSettings::PropagateVersion)
2743+
.subcommand(clap::App::new("subcommand"));
2744+
2745+
assert!(utils::compare_output(
2746+
app.clone(),
2747+
"example help help",
2748+
"example-help
2749+
Print this message or the help of the given subcommand(s)
2750+
2751+
USAGE:
2752+
example help [SUBCOMMAND]...
2753+
2754+
ARGS:
2755+
<SUBCOMMAND>... The subcommand whose help message to display
2756+
",
2757+
false
2758+
));
2759+
2760+
app.debug_assert();
2761+
}

0 commit comments

Comments
 (0)