Skip to content

Commit 11f0e8f

Browse files
committed
chore: apply PR feedback
1 parent 1a97d40 commit 11f0e8f

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

packages/wizard/src/__tests__/parse-args.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ describe('wizard parseArgs — mode resolution', () => {
4343
expect(result.modeError).toMatch(/Unknown --mode value/)
4444
})
4545

46+
it('rejects --mode at the end of argv with a clear error (regression: silent fall-through)', () => {
47+
// Without the trailing-value guard, `--mode` as the final arg falls
48+
// through to the default `implement` with no diagnostic — strictly
49+
// worse than `--mode=` (which already errors). Both forms now surface
50+
// the same "requires a value" error.
51+
const result = parseArgs(argv('--mode'))
52+
expect(result.modeError).toMatch(/--mode requires a value/)
53+
})
54+
4655
it('lets the last mode flag win when multiple are passed', () => {
4756
// Useful for wrappers that always append a mode flag — they don't have
4857
// to detect and remove an earlier one.

packages/wizard/src/bin/parse-args.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ export function parseArgs(argv: string[]): ParsedArgs {
3333
mode = 'implement'
3434
continue
3535
}
36-
if (arg === '--mode' && i + 1 < args.length) {
37-
const next = args[i + 1] ?? ''
36+
if (arg === '--mode') {
37+
if (i + 1 >= args.length) {
38+
modeError = "--mode requires a value. Expected 'plan' or 'implement'."
39+
break
40+
}
41+
const next = args[i + 1]
3842
if (next === 'plan' || next === 'implement') {
3943
mode = next
4044
i++

0 commit comments

Comments
 (0)