fix(cli): validate positive numeric options (#49)

This commit is contained in:
lazyGPT07 2026-06-13 23:55:18 -06:00 • committed by GitHub
parent aa3fdba277
commit fbf4d76372
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 37 additions and 8 deletions

View file

@ -0,0 +1,9 @@
import { InvalidArgumentError } from "commander";
export function parsePositiveInteger(value: string): number {
const parsed = Number(value);
if (value.trim() === "" || !Number.isSafeInteger(parsed) || parsed < 1) {
throw new InvalidArgumentError("must be a positive integer");
}
return parsed;
}