fix(Help Subcommand): fixes issue where help and version flags weren't properly displayed

Closes #466
This commit is contained in:
Kevin K 2016-03-28 11:26:52 -04:00
parent 72ccf0cf6e
commit 205b07bf2e

View file

@ -482,6 +482,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
if &*arg_os == "help" && if &*arg_os == "help" &&
self.settings.is_set(AppSettings::NeedsSubcommandHelp) { self.settings.is_set(AppSettings::NeedsSubcommandHelp) {
let cmds: Vec<OsString> = it.map(|c| c.into()).collect(); let cmds: Vec<OsString> = it.map(|c| c.into()).collect();
let mut sc = {
let mut sc: &Parser = self; let mut sc: &Parser = self;
for (i, cmd) in cmds.iter().enumerate() { for (i, cmd) in cmds.iter().enumerate() {
if let Some(c) = sc.subcommands.iter().filter(|s| &*s.p.meta.name == cmd).next().map(|sc| &sc.p) { if let Some(c) = sc.subcommands.iter().filter(|s| &*s.p.meta.name == cmd).next().map(|sc| &sc.p) {
@ -496,6 +497,9 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
self.meta.bin_name.as_ref().unwrap_or(&self.meta.name))); self.meta.bin_name.as_ref().unwrap_or(&self.meta.name)));
} }
} }
sc.clone()
};
sc.create_help_and_version();
return sc._help(); return sc._help();
} }
subcmd_name = Some(arg_os.to_str().expect(INVALID_UTF8).to_owned()); subcmd_name = Some(arg_os.to_str().expect(INVALID_UTF8).to_owned());