mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 14:54:15 +00:00
fix(Global Args): fixes a bug where globals only transfer to one subcommand
Closes #135
This commit is contained in:
parent
2b6b7ba693
commit
a37842eec1
2 changed files with 27 additions and 2 deletions
|
@ -828,8 +828,8 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
|
|||
-> App<'a, 'v, 'ab, 'u, 'h, 'ar> {
|
||||
if subcmd.name == "help" { self.needs_subcmd_help = false; }
|
||||
{
|
||||
while let Some(a) = self.global_args.pop() {
|
||||
subcmd = subcmd.arg(a);
|
||||
for a in self.global_args.iter() {
|
||||
subcmd = subcmd.arg(a.into());
|
||||
}
|
||||
}
|
||||
self.subcommands.insert(subcmd.name.clone(), subcmd);
|
||||
|
|
|
@ -865,3 +865,28 @@ impl<'n, 'l, 'h, 'g, 'p, 'r> Arg<'n, 'l, 'h, 'g, 'p, 'r> {
|
|||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'n, 'l, 'h, 'g, 'p, 'r, 'z> From<&'z Arg<'n, 'l, 'h, 'g, 'p, 'r>> for Arg<'n, 'l, 'h, 'g, 'p, 'r> {
|
||||
fn from(a: &'z Arg<'n, 'l, 'h, 'g, 'p, 'r>) -> Arg<'n, 'l, 'h, 'g, 'p, 'r> {
|
||||
Arg {
|
||||
name: a.name,
|
||||
short: a.short,
|
||||
long: a.long,
|
||||
help: a.help,
|
||||
required: a.required,
|
||||
takes_value: a.takes_value,
|
||||
multiple: a.multiple,
|
||||
index: a.index,
|
||||
possible_vals: a.possible_vals.clone(),
|
||||
blacklist: a.blacklist.clone(),
|
||||
requires: a.requires.clone(),
|
||||
num_vals: a.num_vals,
|
||||
min_vals: a.min_vals,
|
||||
max_vals: a.max_vals,
|
||||
val_names: a.val_names.clone(),
|
||||
group: a.group,
|
||||
global: a.global,
|
||||
empty_vals: a.empty_vals
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue