mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
Moved some for loops to more readable iterators
This commit is contained in:
parent
bd4de8ff69
commit
ff8ea640e9
1 changed files with 27 additions and 18 deletions
33
src/app.rs
33
src/app.rs
|
@ -526,10 +526,13 @@ impl App {
|
||||||
}
|
}
|
||||||
if let Some(ref reqs) = v.requires {
|
if let Some(ref reqs) = v.requires {
|
||||||
if ! reqs.is_empty() {
|
if ! reqs.is_empty() {
|
||||||
for n in reqs.iter() {
|
// Add all required args which aren't already found in matches to the
|
||||||
if matches.opts.contains_key(n) { continue; }
|
// final required list
|
||||||
if matches.flags.contains_key(n) { continue; }
|
for n in reqs.iter().filter(|&a|
|
||||||
if matches.positionals.contains_key(n) { continue; }
|
! matches.opts.contains_key(a) ||
|
||||||
|
! matches.flags.contains_key(a) ||
|
||||||
|
! matches.positionals.contains_key(a) ) {
|
||||||
|
|
||||||
self.required.insert(n);
|
self.required.insert(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -744,10 +747,13 @@ impl App {
|
||||||
}
|
}
|
||||||
if let Some(ref reqs) = opt.requires {
|
if let Some(ref reqs) = opt.requires {
|
||||||
if ! reqs.is_empty() {
|
if ! reqs.is_empty() {
|
||||||
for n in reqs.iter() {
|
// Add all required args which aren't already found in matches to the
|
||||||
if matches.opts.contains_key(n) { continue; }
|
// final required list
|
||||||
if matches.flags.contains_key(n) { continue; }
|
for n in reqs.iter().filter(|&a|
|
||||||
if matches.positionals.contains_key(n) { continue; }
|
! matches.opts.contains_key(a) ||
|
||||||
|
! matches.flags.contains_key(a) ||
|
||||||
|
! matches.positionals.contains_key(a) ) {
|
||||||
|
|
||||||
self.required.insert(n);
|
self.required.insert(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -810,10 +816,13 @@ impl App {
|
||||||
}
|
}
|
||||||
if let Some(ref reqs) = p.requires {
|
if let Some(ref reqs) = p.requires {
|
||||||
if ! reqs.is_empty() {
|
if ! reqs.is_empty() {
|
||||||
for n in reqs.iter() {
|
// Add all required args which aren't already found in matches to the
|
||||||
if matches.opts.contains_key(n) { continue; }
|
// final required list
|
||||||
if matches.flags.contains_key(n) { continue; }
|
for n in reqs.iter().filter(|&a|
|
||||||
if matches.positionals.contains_key(n) { continue; }
|
! matches.opts.contains_key(a) ||
|
||||||
|
! matches.flags.contains_key(a) ||
|
||||||
|
! matches.positionals.contains_key(a) ) {
|
||||||
|
|
||||||
self.required.insert(n);
|
self.required.insert(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue