@@ -42,92 +42,6 @@ test.set('--option <no value>', async function () {
4242 a . deepEqual ( cla . argv , [ 'one' , 'two' , '--two' , 'three' ] )
4343} )
4444
45- test . set ( 'single --option flag, value set' , async function ( ) {
46- const argv = [ 'one' , 'two' , '--one' , '--two' ]
47- const optionDefinitions = [
48- {
49- name : 'one' ,
50- extractor : 'single' ,
51- single : '--one' ,
52- output : extraction => extraction . length === 1 ? true : undefined
53- }
54- ]
55- const cla = new CommandLineArgs ( argv )
56- const result = await cla . parse ( optionDefinitions )
57- a . deepEqual ( result , { one : true } )
58- a . deepEqual ( cla . argv , [ 'one' , 'two' , '--two' ] )
59- } )
60-
61- test . set ( 'single --option flag, value set not, output returns false' , async function ( ) {
62- const argv = [ 'one' , 'two' , '--two' ]
63- const optionDefinitions = [
64- {
65- name : 'one' ,
66- extractor : 'single' ,
67- single : '--one' ,
68- output : extraction => extraction . length === 1
69- }
70- ]
71- const cla = new CommandLineArgs ( argv )
72- const result = await cla . parse ( optionDefinitions )
73- a . deepEqual ( result , { one : false } )
74- a . deepEqual ( cla . argv , [ 'one' , 'two' , '--two' ] )
75- } )
76-
77- test . set ( 'single --option flag, not set. Returning undefined omits option from result.' , async function ( ) {
78- const argv = [ 'one' , 'two' , '--two' ]
79- const optionDefinitions = [
80- {
81- name : 'one' ,
82- extractor : 'single' ,
83- single : '--one' ,
84- output : extraction => extraction . length === 1 ? true : undefined
85- }
86- ]
87- const cla = new CommandLineArgs ( argv )
88- const result = await cla . parse ( optionDefinitions )
89- a . deepEqual ( result , { } )
90- a . deepEqual ( cla . argv , [ 'one' , 'two' , '--two' ] )
91- } )
92-
93- test . set ( 'single regex' , async function ( ) {
94- const argv = [ 'one' , 'two' , '--one' , '--two' ]
95- const optionDefinitions = [
96- {
97- name : 'one' ,
98- extractor : 'single' ,
99- single : / - - o [ n ] + e / ,
100- output : extraction => true
101- }
102- ]
103- const cla = new CommandLineArgs ( argv )
104- const result = await cla . parse ( optionDefinitions )
105- a . deepEqual ( result , { one : true } )
106- a . deepEqual ( cla . argv , [ 'one' , 'two' , '--two' ] )
107-
108- const argv2 = [ 'one' , 'two' , '--onnnnne' , '--two' ]
109- const cla2 = new CommandLineArgs ( argv2 )
110- const result2 = cla2 . parse ( optionDefinitions )
111- a . deepEqual ( result , { one : true } )
112- a . deepEqual ( cla . argv , [ 'one' , 'two' , '--two' ] )
113- } )
114-
115- test . set ( '--option flag not present' , async function ( ) {
116- const argv = [ 'one' , 'two' , '--not-one' , '--two' ]
117- const optionDefinitions = [
118- {
119- name : 'one' ,
120- extractor : 'single' ,
121- single : '--one' ,
122- output : extraction => extraction . length === 1
123- }
124- ]
125- const cla = new CommandLineArgs ( argv )
126- const result = await cla . parse ( optionDefinitions )
127- a . deepEqual ( result , { one : false } )
128- a . deepEqual ( cla . argv , [ 'one' , 'two' , '--not-one' , '--two' ] )
129- } )
130-
13145test . set ( 'Positionals must be args 1 and 2, with options following' , async function ( ) {
13246 const argv = [ 'positional1' , '100' , '--option' , '4' , '--flag' , 'unwanted' ]
13347
@@ -517,38 +431,4 @@ test.set('Repeating single option values without repeatable set', async function
517431 a . deepEqual ( result , { var : [ '--var' , 'one' ] } )
518432} )
519433
520- test . set ( 'Repeatable singles, raw output' , async function ( ) {
521- const argv = [ '--var' , 'one' , 'something' , '--var' , 'two' , 'another' , '--var' ]
522- const cla = new CommandLineArgs ( argv )
523- const result = await cla . parse ( [
524- {
525- name : 'var' ,
526- extractor : 'single' ,
527- single : '--var' ,
528- repeatable : true ,
529- output : e => e
530- }
531- ] )
532-
533- // this.data = result
534- a . deepEqual ( result , { var : [ [ '--var' ] , [ '--var' ] , [ '--var' ] ] } )
535- } )
536-
537- test . set ( 'Repeatable singles, boolean output' , async function ( ) {
538- const argv = [ '--var' , 'one' , 'something' , '--var' , 'two' , 'another' , '--var' ]
539- const cla = new CommandLineArgs ( argv )
540- const result = await cla . parse ( [
541- {
542- name : 'var' ,
543- extractor : 'single' ,
544- single : '--var' ,
545- repeatable : true ,
546- output : e => e . map ( i => i . length === 1 )
547- }
548- ] )
549-
550- // this.data = result
551- a . deepEqual ( result , { var : [ true , true , true ] } )
552- } )
553-
554434export { test , only , skip }
0 commit comments