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(help): Use display name instead of bin name (unstable-v4) #3693

Merged
merged 2 commits into from May 5, 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
16 changes: 16 additions & 0 deletions src/output/help.rs
Expand Up @@ -32,6 +32,15 @@ pub(crate) struct Help<'help, 'cmd, 'writer> {

// Public Functions
impl<'help, 'cmd, 'writer> Help<'help, 'cmd, 'writer> {
#[cfg(feature = "unstable-v4")]
const DEFAULT_TEMPLATE: &'static str = "\
{before-help}{name} {version}\n\
{author-with-newline}{about-with-newline}\n\
{usage-heading}\n {usage}\n\
\n\
{all-args}{after-help}\
";
#[cfg(not(feature = "unstable-v4"))]
const DEFAULT_TEMPLATE: &'static str = "\
{before-help}{bin} {version}\n\
{author-with-newline}{about-with-newline}\n\
Expand All @@ -40,6 +49,13 @@ impl<'help, 'cmd, 'writer> Help<'help, 'cmd, 'writer> {
{all-args}{after-help}\
";

#[cfg(feature = "unstable-v4")]
const DEFAULT_NO_ARGS_TEMPLATE: &'static str = "\
{before-help}{name} {version}\n\
{author-with-newline}{about-with-newline}\n\
{usage-heading}\n {usage}{after-help}\
";
#[cfg(not(feature = "unstable-v4"))]
const DEFAULT_NO_ARGS_TEMPLATE: &'static str = "\
{before-help}{bin} {version}\n\
{author-with-newline}{about-with-newline}\n\
Expand Down
4 changes: 2 additions & 2 deletions tests/builder/help.rs
Expand Up @@ -2615,7 +2615,7 @@ fn override_help_flag_using_short() {
fn subcommand_help_doesnt_have_useless_help_flag() {
// The main care-about is that the docs and behavior match. Since the `help` subcommand
// currently ignores the `--help` flag, the output shouldn't have it.
let cmd = Command::new("test_app").subcommand(Command::new("test").about("Subcommand"));
let cmd = Command::new("example").subcommand(Command::new("test").about("Subcommand"));

utils::assert_output(
cmd,
Expand Down Expand Up @@ -2655,7 +2655,7 @@ fn disable_help_flag_affects_help_subcommand() {

#[test]
fn dont_propagate_version_to_help_subcommand() {
let cmd = clap::Command::new("test")
let cmd = clap::Command::new("example")
.version("1.0")
.propagate_version(true)
.subcommand(clap::Command::new("subcommand"));
Expand Down