Skip to content

Commit 1fa1656

Browse files
that-github-userunknownclaude
authored
Validate CLI inputs: attempts, timeout, and model (#38)
- --attempts: must be 1-20, reject NaN - --timeout: must be 10-600 seconds, reject NaN - --model: warn (not error) for unknown models, accept claude-* prefixed Closes #21 Co-authored-by: unknown <that-github-user@github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4bcd97f commit 1fa1656

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

src/cli.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,30 @@ program
2424
.option("--model <model>", "Claude model to use", "sonnet")
2525
.option("--verbose", "Show detailed output from each agent")
2626
.action(async (prompt: string, opts) => {
27+
const attempts = parseInt(opts.attempts, 10);
28+
if (Number.isNaN(attempts) || attempts < 1 || attempts > 20) {
29+
console.error("Error: --attempts must be a number between 1 and 20");
30+
process.exit(1);
31+
}
32+
33+
const timeout = parseInt(opts.timeout, 10);
34+
if (Number.isNaN(timeout) || timeout < 10 || timeout > 600) {
35+
console.error("Error: --timeout must be a number between 10 and 600 seconds");
36+
process.exit(1);
37+
}
38+
39+
const knownModels = ["sonnet", "opus", "haiku"];
40+
if (!knownModels.includes(opts.model) && !opts.model.startsWith("claude-")) {
41+
console.warn(
42+
`Warning: unknown model "${opts.model}" — known models: ${knownModels.join(", ")}`,
43+
);
44+
}
45+
2746
await run({
2847
prompt,
29-
attempts: parseInt(opts.attempts, 10),
48+
attempts,
3049
testCmd: opts.testCmd,
31-
timeout: parseInt(opts.timeout, 10),
50+
timeout,
3251
model: opts.model,
3352
verbose: opts.verbose ?? false,
3453
});

0 commit comments

Comments
 (0)