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() {
|
if name == &$arg.name() {
|
||||||
vec_remove!($me.required, name);
|
vec_remove!($me.required, name);
|
||||||
if let Some(ref reqs) = grp.requires {
|
if let Some(ref reqs) = grp.requires {
|
||||||
for r in reqs {
|
$me.required.extend(reqs);
|
||||||
$me.required.push(r);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if let Some(ref bl) = grp.conflicts {
|
if let Some(ref bl) = grp.conflicts {
|
||||||
for &b in bl {
|
$me.blacklist.extend(bl);
|
||||||
$me.blacklist.push(b);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
found = true;
|
found = true; // What if arg is in more than one group with different reqs?
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if found {
|
if found {
|
||||||
for name in &grp.args {
|
vec_remove_all!($me.required, &grp.args);
|
||||||
if name == &$arg.name() { continue }
|
$me.blacklist.extend(&grp.args);
|
||||||
vec_remove!($me.required, name);
|
vec_remove!($me.blacklist, &$arg.name());
|
||||||
|
|
||||||
$me.blacklist.push(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -329,7 +329,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
|
||||||
}
|
}
|
||||||
for g in grps.into_iter() {
|
for g in grps.into_iter() {
|
||||||
let g_string = self.args_in_group(g)
|
let g_string = self.args_in_group(g)
|
||||||
.join(" |");
|
.join("|");
|
||||||
ret_val.push_back(format!("[{}]", &g_string[..g_string.len() - 1]));
|
ret_val.push_back(format!("[{}]", &g_string[..g_string.len() - 1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue