From 08ad1cff4fec57224ea957a2891a057b323c01bc Mon Sep 17 00:00:00 2001 From: Kevin K Date: Thu, 23 Jun 2016 21:32:41 -0400 Subject: [PATCH] fix(Help): subcommand help messages requested via help now correctly match --help Prior to this fix, runnning `prog help subcmd` would produce: ``` subcmd USGAE: [...] ``` Notice lack of `prog-subcmd`. Whereas running `prog subcmd --help` produced: ``` prog-subcmd USGAE: [...] ``` These two forms now match the correct one (latter). Closes #539 --- src/app/parser.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/app/parser.rs b/src/app/parser.rs index e194b154aa7..c4fc574cb51 100644 --- a/src/app/parser.rs +++ b/src/app/parser.rs @@ -564,6 +564,19 @@ impl<'a, 'b> Parser<'a, 'b> sc.clone() }; sc.create_help_and_version(); + if sc.meta.bin_name != self.meta.bin_name { + sc.meta.bin_name = Some(format!("{}{}{}", + self.meta + .bin_name + .as_ref() + .unwrap_or(&String::new()), + if self.meta.bin_name.is_some() { + " " + } else { + "" + }, + &*sc.meta.name)); + } return sc._help(); } subcmd_name = Some(arg_os.to_str().expect(INVALID_UTF8).to_owned());