File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ interface CreateOptions {
3737}
3838
3939interface ParseOptions {
40+ argv ?: string [ ] ;
4041 run ?: boolean ;
4142}
4243
@@ -363,12 +364,15 @@ export class Clerc<
363364 this . #callWithErrorHandler( ( ) => composedInterceptor ( context as any ) ) ;
364365 }
365366
366- public parse (
367- argv : string [ ] = platformArgv ,
368- { run = true } : ParseOptions = { } ,
369- ) : this {
367+ public parse ( argvOrOptions : string [ ] | ParseOptions = platformArgv ) : this {
370368 this . #callWithErrorHandler( ( ) => this . #validate( ) ) ;
371369
370+ if ( Array . isArray ( argvOrOptions ) ) {
371+ argvOrOptions = { argv : argvOrOptions } ;
372+ }
373+
374+ const { argv = platformArgv , run = true } = argvOrOptions ;
375+
372376 this . #argv = argv ;
373377
374378 if ( run ) {
Original file line number Diff line number Diff line change @@ -426,7 +426,7 @@ describe("cli", () => {
426426 . on ( "foo" , ( ) => {
427427 count ++ ;
428428 } )
429- . parse ( [ "foo" ] , { run : false } )
429+ . parse ( { argv : [ "foo" ] , run : false } )
430430 . run ( ) ;
431431
432432 expect ( count ) . toBe ( 1 ) ;
@@ -451,7 +451,7 @@ describe("cli", () => {
451451 . on ( "foo" , ( ) => {
452452 count ++ ;
453453 } )
454- . parse ( [ "foo" ] , { run : false } ) ;
454+ . parse ( { argv : [ "foo" ] , run : false } ) ;
455455
456456 expect ( count ) . toBe ( 0 ) ;
457457 } ) ;
You can’t perform that action at this time.
0 commit comments