fix(Help): subcommand help messages requested via <cmd> help <sub> now correctly match <cmd> <sub> --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
This commit is contained in:
Kevin K 2016-06-23 21:32:41 -04:00
parent 89d208eb7b
commit 08ad1cff4f

View file

@ -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());