@@ -3,6 +3,7 @@ use std::ops::RangeBounds;
3
3
4
4
use crate :: builder:: Str ;
5
5
use crate :: builder:: StyledStr ;
6
+ use crate :: parser:: ValueSource ;
6
7
use crate :: util:: AnyValue ;
7
8
use crate :: util:: AnyValueId ;
8
9
@@ -236,8 +237,9 @@ impl ValueParser {
236
237
cmd : & crate :: Command ,
237
238
arg : Option < & crate :: Arg > ,
238
239
value : & std:: ffi:: OsStr ,
240
+ source : ValueSource ,
239
241
) -> Result < AnyValue , crate :: Error > {
240
- self . any_value_parser ( ) . parse_ref ( cmd, arg, value)
242
+ self . any_value_parser ( ) . parse_ref_ ( cmd, arg, value, source )
241
243
}
242
244
243
245
/// Describes the content of `AnyValue`
@@ -594,13 +596,33 @@ trait AnyValueParser: Send + Sync + 'static {
594
596
value : & std:: ffi:: OsStr ,
595
597
) -> Result < AnyValue , crate :: Error > ;
596
598
599
+ fn parse_ref_ (
600
+ & self ,
601
+ cmd : & crate :: Command ,
602
+ arg : Option < & crate :: Arg > ,
603
+ value : & std:: ffi:: OsStr ,
604
+ _source : ValueSource ,
605
+ ) -> Result < AnyValue , crate :: Error > {
606
+ self . parse_ref ( cmd, arg, value)
607
+ }
608
+
597
609
fn parse (
598
610
& self ,
599
611
cmd : & crate :: Command ,
600
612
arg : Option < & crate :: Arg > ,
601
613
value : std:: ffi:: OsString ,
602
614
) -> Result < AnyValue , crate :: Error > ;
603
615
616
+ fn parse_ (
617
+ & self ,
618
+ cmd : & crate :: Command ,
619
+ arg : Option < & crate :: Arg > ,
620
+ value : std:: ffi:: OsString ,
621
+ _source : ValueSource ,
622
+ ) -> Result < AnyValue , crate :: Error > {
623
+ self . parse ( cmd, arg, value)
624
+ }
625
+
604
626
/// Describes the content of `AnyValue`
605
627
fn type_id ( & self ) -> AnyValueId ;
606
628
@@ -626,6 +648,17 @@ where
626
648
Ok ( AnyValue :: new ( value) )
627
649
}
628
650
651
+ fn parse_ref_ (
652
+ & self ,
653
+ cmd : & crate :: Command ,
654
+ arg : Option < & crate :: Arg > ,
655
+ value : & std:: ffi:: OsStr ,
656
+ source : ValueSource ,
657
+ ) -> Result < AnyValue , crate :: Error > {
658
+ let value = ok ! ( TypedValueParser :: parse_ref_( self , cmd, arg, value, source) ) ;
659
+ Ok ( AnyValue :: new ( value) )
660
+ }
661
+
629
662
fn parse (
630
663
& self ,
631
664
cmd : & crate :: Command ,
@@ -636,6 +669,17 @@ where
636
669
Ok ( AnyValue :: new ( value) )
637
670
}
638
671
672
+ fn parse_ (
673
+ & self ,
674
+ cmd : & crate :: Command ,
675
+ arg : Option < & crate :: Arg > ,
676
+ value : std:: ffi:: OsString ,
677
+ source : ValueSource ,
678
+ ) -> Result < AnyValue , crate :: Error > {
679
+ let value = ok ! ( TypedValueParser :: parse_( self , cmd, arg, value, source) ) ;
680
+ Ok ( AnyValue :: new ( value) )
681
+ }
682
+
639
683
fn type_id ( & self ) -> AnyValueId {
640
684
AnyValueId :: of :: < T > ( )
641
685
}
@@ -716,6 +760,19 @@ pub trait TypedValueParser: Clone + Send + Sync + 'static {
716
760
value : & std:: ffi:: OsStr ,
717
761
) -> Result < Self :: Value , crate :: Error > ;
718
762
763
+ /// Parse the argument value
764
+ ///
765
+ /// When `arg` is `None`, an external subcommand value is being parsed.
766
+ fn parse_ref_ (
767
+ & self ,
768
+ cmd : & crate :: Command ,
769
+ arg : Option < & crate :: Arg > ,
770
+ value : & std:: ffi:: OsStr ,
771
+ _source : ValueSource ,
772
+ ) -> Result < Self :: Value , crate :: Error > {
773
+ self . parse_ref ( cmd, arg, value)
774
+ }
775
+
719
776
/// Parse the argument value
720
777
///
721
778
/// When `arg` is `None`, an external subcommand value is being parsed.
@@ -728,6 +785,19 @@ pub trait TypedValueParser: Clone + Send + Sync + 'static {
728
785
self . parse_ref ( cmd, arg, & value)
729
786
}
730
787
788
+ /// Parse the argument value
789
+ ///
790
+ /// When `arg` is `None`, an external subcommand value is being parsed.
791
+ fn parse_ (
792
+ & self ,
793
+ cmd : & crate :: Command ,
794
+ arg : Option < & crate :: Arg > ,
795
+ value : std:: ffi:: OsString ,
796
+ _source : ValueSource ,
797
+ ) -> Result < Self :: Value , crate :: Error > {
798
+ self . parse ( cmd, arg, value)
799
+ }
800
+
731
801
/// Reflect on enumerated value properties
732
802
///
733
803
/// Error checking should not be done with this; it is mostly targeted at user-facing
0 commit comments