mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
fix(Help Subcommand): fixes issue where help and version flags weren't properly displayed
Closes #466
This commit is contained in:
parent
72ccf0cf6e
commit
205b07bf2e
1 changed files with 16 additions and 12 deletions
|
@ -482,6 +482,7 @@ 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 = {
|
||||
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) {
|
||||
|
@ -496,6 +497,9 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
|
|||
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());
|
||||
|
|
Loading…
Reference in a new issue