File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 1
1
#[ cfg( debug_assertions) ]
2
2
use crate :: util:: AnyValueId ;
3
3
4
+ use crate :: builder:: ValueRange ;
5
+
4
6
/// Behavior of arguments when they are encountered while parsing
5
7
///
6
8
/// # Examples
@@ -369,6 +371,20 @@ impl ArgAction {
369
371
}
370
372
}
371
373
374
+ pub ( crate ) fn default_num_args ( & self ) -> ValueRange {
375
+ match self {
376
+ Self :: Set => ValueRange :: SINGLE ,
377
+ Self :: Append => ValueRange :: SINGLE ,
378
+ Self :: SetTrue => ValueRange :: EMPTY ,
379
+ Self :: SetFalse => ValueRange :: EMPTY ,
380
+ Self :: Count => ValueRange :: EMPTY ,
381
+ Self :: Help => ValueRange :: EMPTY ,
382
+ Self :: HelpShort => ValueRange :: EMPTY ,
383
+ Self :: HelpLong => ValueRange :: EMPTY ,
384
+ Self :: Version => ValueRange :: EMPTY ,
385
+ }
386
+ }
387
+
372
388
pub ( crate ) fn default_value ( & self ) -> Option < & ' static std:: ffi:: OsStr > {
373
389
match self {
374
390
Self :: Set => None ,
Original file line number Diff line number Diff line change @@ -4546,11 +4546,7 @@ impl Arg {
4546
4546
if val_names_len > 1 {
4547
4547
self . num_vals . get_or_insert ( val_names_len. into ( ) ) ;
4548
4548
} else {
4549
- let nargs = if self . get_action ( ) . takes_values ( ) {
4550
- ValueRange :: SINGLE
4551
- } else {
4552
- ValueRange :: EMPTY
4553
- } ;
4549
+ let nargs = self . get_action ( ) . default_num_args ( ) ;
4554
4550
self . num_vals . get_or_insert ( nargs) ;
4555
4551
}
4556
4552
}
You can’t perform that action at this time.
0 commit comments