mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
refactor(macros): implements a better _handle_group_reqs
This commit is contained in:
parent
de32078d75
commit
8f145f1024
2 changed files with 7 additions and 14 deletions
|
@ -86,26 +86,19 @@ macro_rules! _handle_group_reqs{
|
|||
if name == &$arg.name() {
|
||||
vec_remove!($me.required, name);
|
||||
if let Some(ref reqs) = grp.requires {
|
||||
for r in reqs {
|
||||
$me.required.push(r);
|
||||
}
|
||||
$me.required.extend(reqs);
|
||||
}
|
||||
if let Some(ref bl) = grp.conflicts {
|
||||
for &b in bl {
|
||||
$me.blacklist.push(b);
|
||||
$me.blacklist.extend(bl);
|
||||
}
|
||||
}
|
||||
found = true;
|
||||
found = true; // What if arg is in more than one group with different reqs?
|
||||
break;
|
||||
}
|
||||
}
|
||||
if found {
|
||||
for name in &grp.args {
|
||||
if name == &$arg.name() { continue }
|
||||
vec_remove!($me.required, name);
|
||||
|
||||
$me.blacklist.push(name);
|
||||
}
|
||||
vec_remove_all!($me.required, &grp.args);
|
||||
$me.blacklist.extend(&grp.args);
|
||||
vec_remove!($me.blacklist, &$arg.name());
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -329,7 +329,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
|
|||
}
|
||||
for g in grps.into_iter() {
|
||||
let g_string = self.args_in_group(g)
|
||||
.join(" |");
|
||||
.join("|");
|
||||
ret_val.push_back(format!("[{}]", &g_string[..g_string.len() - 1]));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue