@@ -2180,7 +2180,7 @@ describe('yargs-parser', function () {
21802180
21812181 parsed [ 'x' ] . should . deep . equal ( [ 'a' , 'b' ] )
21822182 } )
2183- it ( 'keeps only last argument' , function ( ) {
2183+ it ( 'string: keeps only last argument' , function ( ) {
21842184 var parsed = parser ( '-x a -x b' , {
21852185 configuration : {
21862186 'duplicate-arguments-array' : false
@@ -2189,6 +2189,26 @@ describe('yargs-parser', function () {
21892189
21902190 parsed [ 'x' ] . should . equal ( 'b' )
21912191 } )
2192+ it ( 'array[string]: keeps only last argument' , function ( ) {
2193+ var parsed = parser ( '-x a -x b' , {
2194+ configuration : {
2195+ array : [ { key : 'x' , string : true } ] ,
2196+ 'duplicate-arguments-array' : false
2197+ }
2198+ } )
2199+
2200+ parsed [ 'x' ] . should . equal ( 'b' )
2201+ } )
2202+ it ( 'array[number]: keeps only last argument' , function ( ) {
2203+ var parsed = parser ( '-x 1 -x 2' , {
2204+ configuration : {
2205+ array : [ { key : 'x' , number : true } ] ,
2206+ 'duplicate-arguments-array' : false
2207+ }
2208+ } )
2209+
2210+ parsed [ 'x' ] . should . equal ( 2 )
2211+ } )
21922212 } )
21932213
21942214 describe ( 'flatten duplicate arrays' , function ( ) {
@@ -2385,25 +2405,25 @@ describe('yargs-parser', function () {
23852405 } )
23862406 describe ( 'duplicate=true, flatten=false,' , function ( ) {
23872407 describe ( 'type=array' , function ( ) {
2388- it ( '[-x 1 -x 2 -x 3] => [1, 2, 3]' , function ( ) {
2408+ it ( 'number: [-x 1 -x 2 -x 3] => [[1], [2], [ 3]' , function ( ) {
23892409 var parsed = parser ( '-x 1 -x 2 -x 3' , {
2390- array : [ 'x' ] ,
2410+ array : [ { key : 'x' , number : true } ] ,
23912411 configuration : {
23922412 'duplicate-arguments-array' : true ,
23932413 'flatten-duplicate-arrays' : false
23942414 }
23952415 } )
2396- parsed [ 'x' ] . should . deep . equal ( [ 1 , 2 , 3 ] )
2416+ parsed [ 'x' ] . should . deep . equal ( [ [ 1 ] , [ 2 ] , [ 3 ] ] )
23972417 } )
2398- it ( '[-x 1 2 3 -x 2 3 4 ] => [[1, 2, 3 ], [ 2, 3, 4] ]' , function ( ) {
2399- var parsed = parser ( '-x 1 2 3 -x 2 3 4 ' , {
2400- array : [ 'x' ] ,
2418+ it ( 'string: [-x 1 -x 2 -x 3 ] => [[1], [2], [3 ]' , function ( ) {
2419+ var parsed = parser ( '-x 1 -x 2 -x 3 ' , {
2420+ array : [ { key : 'x' , string : true } ] ,
24012421 configuration : {
24022422 'duplicate-arguments-array' : true ,
24032423 'flatten-duplicate-arrays' : false
24042424 }
24052425 } )
2406- parsed [ 'x' ] . should . deep . equal ( [ [ 1 , 2 , 3 ] , [ 2 , 3 , 4 ] ] )
2426+ parsed [ 'x' ] . should . deep . equal ( [ [ '1' ] , [ '2' ] , [ '3' ] ] )
24072427 } )
24082428 } )
24092429 describe ( 'type=number' , function ( ) {
0 commit comments