diff --git a/src/output/help_template.rs b/src/output/help_template.rs index 3db80da7be6f..6fe9db1b4a7e 100644 --- a/src/output/help_template.rs +++ b/src/output/help_template.rs @@ -137,6 +137,7 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> { "name" => { self.write_display_name(); } + #[cfg(not(feature = "unstable-v5"))] "bin" => { self.write_bin_name(); } diff --git a/tests/builder/help.rs b/tests/builder/help.rs index ce1c1156966a..dbd8084a9b41 100644 --- a/tests/builder/help.rs +++ b/tests/builder/help.rs @@ -1042,6 +1042,27 @@ Options: -V, --version Print version information "; + #[cfg(not(feature = "unstable-v5"))] + let cmd = Command::new("ripgrep") + .version("0.5") + .override_usage( + "\ + rg [OPTIONS] [ ...] + rg [OPTIONS] [-e PATTERN | -f FILE ]... [ ...] + rg [OPTIONS] --files [ ...] + rg [OPTIONS] --type-list", + ) + .help_template( + "\ +{bin} {version} + +Usage: {usage} + +Options: +{options}", + ); + + #[cfg(feature = "unstable-v5")] let cmd = Command::new("ripgrep") .version("0.5") .override_usage( diff --git a/tests/builder/template_help.rs b/tests/builder/template_help.rs index 5ca017ab3382..4d305a24490d 100644 --- a/tests/builder/template_help.rs +++ b/tests/builder/template_help.rs @@ -2,6 +2,16 @@ use super::utils; use clap::{arg, Command}; +#[cfg(not(feature = "unstable-v5"))] +static EXAMPLE1_TMPL_S: &str = "{bin} {version} +{author} +{about} + +Usage: {usage} + +{all-args}"; + +#[cfg(feature = "unstable-v5")] static EXAMPLE1_TMPL_S: &str = "{name} {version} {author} {about} @@ -10,6 +20,21 @@ Usage: {usage} {all-args}"; +#[cfg(not(feature = "unstable-v5"))] +static EXAMPLE1_TMPS_F: &str = "{bin} {version} +{author} +{about} + +Usage: {usage} + +Options: +{options} +Arguments: +{positionals} +Commands: +{subcommands}"; + +#[cfg(feature = "unstable-v5")] static EXAMPLE1_TMPS_F: &str = "{name} {version} {author} {about} @@ -105,11 +130,20 @@ fn template_unknowntag() { #[test] fn template_author_version() { + #[cfg(not(feature = "unstable-v5"))] + let cmd = Command::new("MyApp") + .version("1.0") + .author("Kevin K. ") + .about("Does awesome things") + .help_template("{author}\n{version}\n{about}\n{bin}"); + + #[cfg(feature = "unstable-v5")] let cmd = Command::new("MyApp") .version("1.0") .author("Kevin K. ") .about("Does awesome things") .help_template("{author}\n{version}\n{about}\n{name}"); + utils::assert_output( cmd, "MyApp --help",