@@ -1608,13 +1608,10 @@ impl<'a, 'b> Parser<'a, 'b>
1608
1608
fn validate_num_args ( & self , matcher : & mut ArgMatcher ) -> ClapResult < ( ) > {
1609
1609
debugln ! ( "fn=validate_num_args;" ) ;
1610
1610
for ( name, ma) in matcher. iter ( ) {
1611
- if self . groups . contains_key ( & * * name) {
1612
- continue ;
1613
- } else if let Some ( opt) = find_by_name ! ( self , name, opts, iter) {
1611
+ debugln ! ( "iter;name={}" , name) ;
1612
+ if let Some ( opt) = find_by_name ! ( self , name, opts, iter) {
1614
1613
try!( self . _validate_num_vals ( opt, ma, matcher) ) ;
1615
- } else if let Some ( pos) = self . positionals
1616
- . values ( )
1617
- . find ( |p| & p. b . name == name) {
1614
+ } else if let Some ( pos) = find_by_name ! ( self , name, positionals, values) {
1618
1615
try!( self . _validate_num_vals ( pos, ma, matcher) ) ;
1619
1616
}
1620
1617
}
@@ -1685,7 +1682,9 @@ impl<'a, 'b> Parser<'a, 'b>
1685
1682
}
1686
1683
1687
1684
fn validate_required ( & self , matcher : & ArgMatcher ) -> ClapResult < ( ) > {
1685
+ debugln ! ( "fn=validate_required;required={:?};" , self . required) ;
1688
1686
' outer: for name in & self . required {
1687
+ debugln ! ( "iter;name={}" , name) ;
1689
1688
if matcher. contains ( name) {
1690
1689
continue ' outer;
1691
1690
}
@@ -1735,27 +1734,36 @@ impl<'a, 'b> Parser<'a, 'b>
1735
1734
fn is_missing_required_ok < A > ( & self , a : & A , matcher : & ArgMatcher ) -> bool
1736
1735
where A : AnyArg < ' a , ' b >
1737
1736
{
1737
+ debugln ! ( "fn=is_missing_required_ok;a={}" , a. name( ) ) ;
1738
1738
if let Some ( bl) = a. blacklist ( ) {
1739
+ debugln ! ( "Conflicts found...{:?}" , bl) ;
1739
1740
for n in bl. iter ( ) {
1741
+ debugln ! ( "iter;conflict={}" , n) ;
1740
1742
if matcher. contains ( n) ||
1741
1743
self . groups
1742
1744
. get ( n)
1743
1745
. map_or ( false , |g| g. args . iter ( ) . any ( |an| matcher. contains ( an) ) ) {
1744
1746
return true ;
1745
1747
}
1746
1748
}
1747
- } else if let Some ( ru) = a. required_unless ( ) {
1749
+ }
1750
+ if let Some ( ru) = a. required_unless ( ) {
1751
+ debugln ! ( "Required unless found...{:?}" , ru) ;
1748
1752
let mut found_any = false ;
1749
1753
for n in ru. iter ( ) {
1754
+ debugln ! ( "iter;ru={}" , n) ;
1750
1755
if matcher. contains ( n) ||
1751
1756
self . groups
1752
1757
. get ( n)
1753
1758
. map_or ( false , |g| g. args . iter ( ) . any ( |an| matcher. contains ( an) ) ) {
1754
1759
if !a. is_set ( ArgSettings :: RequiredUnlessAll ) {
1760
+ debugln ! ( "Doesn't require all...returning true" ) ;
1755
1761
return true ;
1756
1762
}
1763
+ debugln ! ( "Requires all...next" ) ;
1757
1764
found_any = true ;
1758
1765
} else if a. is_set ( ArgSettings :: RequiredUnlessAll ) {
1766
+ debugln ! ( "Not in matcher, or group and requires all...returning false" ) ;
1759
1767
return false ;
1760
1768
}
1761
1769
}
0 commit comments