File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed
clap_complete/tests/testsuite Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -768,6 +768,63 @@ pos_2_c
768
768
) ;
769
769
}
770
770
771
+ #[ test]
772
+ fn suggest_multi_positional_unbounded ( ) {
773
+ let mut cmd = Command :: new ( "dynamic" )
774
+ . arg (
775
+ clap:: Arg :: new ( "positional" )
776
+ . value_parser ( [ "pos_1" , "pos_2" ] )
777
+ . index ( 1 )
778
+ . num_args ( 2 ..) ,
779
+ )
780
+ . arg (
781
+ clap:: Arg :: new ( "--format" )
782
+ . long ( "format" )
783
+ . short ( 'F' )
784
+ . value_parser ( [ "json" , "yaml" , "toml" ] ) ,
785
+ ) ;
786
+
787
+ assert_data_eq ! (
788
+ complete!( cmd, "pos_1 [TAB]" ) ,
789
+ snapbox:: str ![ [ r#"
790
+ pos_1
791
+ pos_2
792
+ "# ] ]
793
+ ) ;
794
+
795
+ assert_data_eq ! ( complete!( cmd, "pos_1 --[TAB]" ) , snapbox:: str ![ "" ] ) ;
796
+
797
+ assert_data_eq ! (
798
+ complete!( cmd, "pos_1 --format [TAB]" ) ,
799
+ snapbox:: str ![ [ r#"
800
+ json
801
+ yaml
802
+ toml
803
+ "# ] ]
804
+ ) ;
805
+
806
+ assert_data_eq ! (
807
+ complete!( cmd, "pos_1 --format json [TAB]" ) ,
808
+ snapbox:: str ![ [ r#"
809
+ pos_1
810
+ pos_2
811
+ --format
812
+ --help Print help
813
+ "# ] ]
814
+ ) ;
815
+
816
+ assert_data_eq ! ( complete!( cmd, "pos_1 pos_2 --[TAB]" ) , snapbox:: str ![ "" ] ) ;
817
+ assert_data_eq ! (
818
+ complete!( cmd, "pos_1 pos_2 --format json [TAB]" ) ,
819
+ snapbox:: str ![ [ r#"
820
+ pos_1
821
+ pos_2
822
+ --format
823
+ --help Print help
824
+ "# ] ]
825
+ ) ;
826
+ }
827
+
771
828
#[ test]
772
829
fn suggest_delimiter_values ( ) {
773
830
let mut cmd = Command :: new ( "delimiter" )
You can’t perform that action at this time.
0 commit comments