fix: reject partial numeric CLI options

This commit is contained in:
Peter Steinberger
2026-05-27 03:34:44 -04:00
parent f4e20f806e
commit d2d5010aec
13 changed files with 195 additions and 32 deletions

View File

@@ -1,3 +1,4 @@
import { Command } from "commander";
import { beforeEach, describe, expect, it, vi } from "vitest";
const mocks = vi.hoisted(() => {
@@ -35,6 +36,7 @@ vi.mock("../infra/clawhub.js", () => ({
}));
const { runPluginsSearchCommand } = await import("./plugins-search-command.js");
const { registerPluginsCli } = await import("./plugins-cli.js");
describe("plugins search command", () => {
beforeEach(() => {
@@ -107,4 +109,15 @@ describe("plugins search command", () => {
expect(mocks.runtime.writeJson).toHaveBeenCalledWith({ results: [] }, 2);
});
it("rejects partial numeric search limits", async () => {
const program = new Command();
program.exitOverride();
registerPluginsCli(program);
await expect(
program.parseAsync(["plugins", "search", "calendar", "--limit", "10ms"], { from: "user" }),
).rejects.toThrow("--limit must be a positive integer.");
expect(mocks.searchClawHubPackages).not.toHaveBeenCalled();
});
});