Skip to content

Commit

Permalink
fix(Global Args): fixes a bug where globals only transfer to one subc…
Browse files Browse the repository at this point in the history
…ommand

Closes #135
  • Loading branch information
kbknapp committed May 31, 2015
1 parent 2b6b7ba commit a37842e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 25 additions & 0 deletions src/args/arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

0 comments on commit a37842e

Please sign in to comment.