@@ -224,106 +224,3 @@ export function parseSubVerb(ctx: ParseContext, result: ParseResult,
224224 parseVerb ( ctx , subRes , verbDef ) ;
225225 result . set ( verbDef . id , subRes ) ;
226226}
227-
228-
229-
230-
231-
232-
233- declare const scriptArgs : string [ ] ;
234-
235- const info : CmdVerb = {
236- id : 'cmd' ,
237- name : 'cmd' ,
238- options : [
239- {
240- id : 'opt' ,
241- names : [ '--opt' , '--bac' , '-o' ] ,
242- args : [
243- {
244- id : 'num' ,
245- type : ( ctx ) => + ctx . consumeToken ( ) ,
246- } ,
247- {
248- id : 'hello' ,
249- type : ( ctx ) => ctx . consumeToken ( ) ,
250- default : 1 ,
251- optional : true ,
252- }
253- ]
254- } ,
255- {
256- id : 'another' ,
257- names : [ '--another' , '--ano' , '-a' ] ,
258- args : [
259- {
260- id : 'val' ,
261- type : ( ctx ) => {
262- const tok = ctx . consumeToken ( ) ;
263- if ( ! / ^ [ + - ] ? [ 0 - 9 ] + (?: \. [ 0 - 9 ] + ) ? $ / . test ( tok ) )
264- throw 'invalid number: ' + tok ;
265- return + tok ;
266- } ,
267- optional : true ,
268- default : 0 ,
269- }
270- ]
271- } ,
272- {
273- id : 'verbose' ,
274- names : [ '-v' , '--verbose' ] ,
275- }
276- ] ,
277- args : [
278- {
279- id : 'arg1S' ,
280- type : ( ctx ) => ctx . consumeToken ( ) ,
281- } ,
282- {
283- id : 'arg2B' ,
284- type : ( ctx ) => {
285- const tok = ctx . consumeToken ( ) ;
286- const val = [ 'false' , 'true' ] . indexOf ( tok ) ;
287- if ( val == - 1 ) throw 'invalid boolean: ' + tok ;
288- return ! ! val ;
289- } ,
290- } ,
291- {
292- id : 'arg3N' ,
293- type : ( ctx ) => + ctx . consumeToken ( ) ,
294- optional : true ,
295- default : 391
296- }
297- ] ,
298- subverbs : [
299- {
300- id : 'sub' ,
301- name : 'sub' ,
302- args : [
303- {
304- id : 'subArg' ,
305- type : ( ctx ) => ctx . consumeToken ( ) ,
306- optional : true ,
307- }
308- ] ,
309- options : [
310- {
311- id : 'subOpt' ,
312- names : [ '--sub' , '-s' ] ,
313- args : [
314- {
315- id : 'subOptArg' ,
316- type : ( ctx ) => ctx . consumeToken ( ) ,
317- }
318- ]
319- }
320- ]
321- }
322- ]
323- } ;
324-
325- const ctx = new ParseContext ( scriptArgs . slice ( 1 ) ) ;
326- const result = new ParseResult ( ) ;
327-
328- parseVerb ( ctx , result , info ) ;
329- console . log ( JSON . stringify ( result . getMap ( ) ) ) ;
0 commit comments