mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-13 19:26:02 +00:00
fix: reject partial numeric CLI options
This commit is contained in:
@@ -3,6 +3,7 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
collectOption,
|
||||
parsePositiveIntOrUndefined,
|
||||
parseStrictPositiveIntOption,
|
||||
parseStrictPositiveIntOrUndefined,
|
||||
resolveActionArgs,
|
||||
resolveCommandOptionArgs,
|
||||
@@ -53,6 +54,13 @@ describe("program helpers", () => {
|
||||
expect(parseStrictPositiveIntOrUndefined(value)).toBe(expected);
|
||||
});
|
||||
|
||||
it("parseStrictPositiveIntOption rejects partial numeric strings", () => {
|
||||
expect(parseStrictPositiveIntOption("10", "--limit")).toBe(10);
|
||||
expect(() => parseStrictPositiveIntOption("10ms", "--limit")).toThrow(
|
||||
"--limit must be a positive integer.",
|
||||
);
|
||||
});
|
||||
|
||||
it("resolveActionArgs returns args when command has arg array", () => {
|
||||
const command = new Command();
|
||||
(command as Command & { args?: string[] }).args = ["one", "two"];
|
||||
|
||||
Reference in New Issue
Block a user