Skip to content

Commit a37842e

Browse files
committed
fix(Global Args): fixes a bug where globals only transfer to one subcommand
Closes #135
1 parent 2b6b7ba commit a37842e

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/app.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -828,8 +828,8 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
828828
-> App<'a, 'v, 'ab, 'u, 'h, 'ar> {
829829
if subcmd.name == "help" { self.needs_subcmd_help = false; }
830830
{
831-
while let Some(a) = self.global_args.pop() {
832-
subcmd = subcmd.arg(a);
831+
for a in self.global_args.iter() {
832+
subcmd = subcmd.arg(a.into());
833833
}
834834
}
835835
self.subcommands.insert(subcmd.name.clone(), subcmd);

src/args/arg.rs

+25
Original file line numberDiff line numberDiff line change
@@ -865,3 +865,28 @@ impl<'n, 'l, 'h, 'g, 'p, 'r> Arg<'n, 'l, 'h, 'g, 'p, 'r> {
865865
self
866866
}
867867
}
868+
869+
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> {
870+
fn from(a: &'z Arg<'n, 'l, 'h, 'g, 'p, 'r>) -> Arg<'n, 'l, 'h, 'g, 'p, 'r> {
871+
Arg {
872+
name: a.name,
873+
short: a.short,
874+
long: a.long,
875+
help: a.help,
876+
required: a.required,
877+
takes_value: a.takes_value,
878+
multiple: a.multiple,
879+
index: a.index,
880+
possible_vals: a.possible_vals.clone(),
881+
blacklist: a.blacklist.clone(),
882+
requires: a.requires.clone(),
883+
num_vals: a.num_vals,
884+
min_vals: a.min_vals,
885+
max_vals: a.max_vals,
886+
val_names: a.val_names.clone(),
887+
group: a.group,
888+
global: a.global,
889+
empty_vals: a.empty_vals
890+
}
891+
}
892+
}

0 commit comments

Comments
 (0)