Auto merge of #467 - kbknapp:issue-466, r=kbknapp

fix(Help Subcommand): fixes issue where help and version flags weren'…

…t properly displayed

Closes #466
This commit is contained in:
Homu 2016-03-29 11:38:05 +09:00
commit 157f981b09
3 changed files with 25 additions and 13 deletions

View file

@ -1,3 +1,11 @@
<a name="v2.2.3"></a>
### v2.2.3 (2016-03-28)
#### Bug Fixes
* **Help Subcommand:** fixes issue where help and version flags weren't properly displayed ([205b07bf](https://github.com/kbknapp/clap-rs/commit/205b07bf2e6547851f1290f8cd6b169145e144f1), closes [#466](https://github.com/kbknapp/clap-rs/issues/466))
<a name="v2.2.2"></a>
### v2.2.2 (2016-03-27)

View file

@ -1,7 +1,7 @@
[package]
name = "clap"
version = "2.2.2"
version = "2.2.3"
authors = ["Kevin K. <kbknapp@gmail.com>"]
exclude = ["examples/*", "clap-tests/*", "tests/*", "benches/*", "*.png", "clap-perf/*"]
description = "A simple to use, efficient, and full featured Command Line Argument Parser"

View file

@ -482,20 +482,24 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
if &*arg_os == "help" &&
self.settings.is_set(AppSettings::NeedsSubcommandHelp) {
let cmds: Vec<OsString> = it.map(|c| c.into()).collect();
let mut sc: &Parser = self;
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) {
sc = c;
if i == cmds.len() - 1 {
break;
let mut sc = {
let mut sc: &Parser = self;
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) {
sc = c;
if i == cmds.len() - 1 {
break;
}
} else {
return Err(
Error::unrecognized_subcommand(
cmd.to_string_lossy().into_owned(),
self.meta.bin_name.as_ref().unwrap_or(&self.meta.name)));
}
} else {
return Err(
Error::unrecognized_subcommand(
cmd.to_string_lossy().into_owned(),
self.meta.bin_name.as_ref().unwrap_or(&self.meta.name)));
}
}
sc.clone()
};
sc.create_help_and_version();
return sc._help();
}
subcmd_name = Some(arg_os.to_str().expect(INVALID_UTF8).to_owned());