Skip to content

Commit 93c4e77

Browse files
committed
feat!: move argv to ParseOptions
1 parent 18e663d commit 93c4e77

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

packages/core/src/cli.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ interface CreateOptions {
3737
}
3838

3939
interface 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) {

packages/core/test/cli.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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
});

0 commit comments

Comments
 (0)