Skip to content

Commit 6dd3a6a

Browse files
committed
fix(sim-cli): an unknown option on a command with no options says so
1 parent 9d64913 commit 6dd3a6a

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎packages/sim-cli/src/embed-isolation.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,14 @@ describe('embedded CLI output ownership', () => {
9292
const transport = async () => {
9393
throw new Error('a parse error must not reach the API')
9494
}
95-
const [guessed, dashedId, noArguments] = await Promise.all([
95+
const [guessed, dashedId, noArguments, noOptions] = await Promise.all([
9696
runEmbeddedCli(['tables', 'rows', 'batch-delete', 'tbl_1', '--row-ids', 'row_1', '--yes'], {
9797
...identity,
9898
transport,
9999
}),
100100
runEmbeddedCli(['audit-logs', 'get', '-X9abc'], { ...identity, transport }),
101101
runEmbeddedCli(['logs', 'list', '-X9abc'], { ...identity, transport }),
102+
runEmbeddedCli(['workspaces', 'get', 'ws_1', '--verbose'], { ...identity, transport }),
102103
])
103104
expect(guessed.exitCode).toBe(1)
104105
expect(guessed.stderr).toContain("unknown option '--row-ids'")
@@ -111,5 +112,9 @@ describe('embedded CLI output ownership', () => {
111112
expect(noArguments.exitCode).toBe(1)
112113
expect(noArguments.stderr).toContain('Options for sim logs list:')
113114
expect(noArguments.stderr).not.toContain('Example:')
115+
// An empty list reads as truncated output rather than as an answer.
116+
expect(noOptions.exitCode).toBe(1)
117+
expect(noOptions.stderr).toContain('sim workspaces get takes no options.')
118+
expect(noOptions.stderr).not.toContain('Options for')
114119
})
115120
})

‎packages/sim-cli/src/runtime/build.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ function addParseErrorGuidance(command: Command): Command {
123123
return
124124
}
125125
const flags = command.options.filter((option) => !option.hidden).map((option) => option.flags)
126-
write(`Options for ${commandPath(command)}: ${flags.join(', ')}\n`)
126+
write(
127+
flags.length > 0
128+
? `Options for ${commandPath(command)}: ${flags.join(', ')}\n`
129+
: `${commandPath(command)} takes no options.\n`
130+
)
127131
},
128132
})
129133
return command

0 commit comments

Comments
 (0)