fix(cli): prevent boolean flags from swallowing positional args and unify aipro arg parsing
This commit is contained in:
1 parent
d0af46b445
commit
c60d49fb8c
4 files changed
+117
-25
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { runCli } from "./runner.js";
|
||||
import { parseArgs, booleanOption } from "./parser.js";
|
||||
import { VERSION_INFO, formatVersionLabel } from "../version.js";
|
||||
|
||||
describe("CLI runner - version and help aliases", () => {
|
||||
@@ -98,4 +99,19 @@ describe("CLI runner - version and help aliases", () => {
|
||||
expect(help.stderr).toBe("");
|
||||
expect(version.stderr).toBe("");
|
||||
});
|
||||
|
||||
it("does not swallow positional arguments after subcommand boolean flags", () => {
|
||||
const parsed1 = parseArgs(["feetype", "get", "--all", "FT001"]);
|
||||
expect(booleanOption(parsed1.options, ["all"])).toBe(true);
|
||||
expect(parsed1.args).toEqual(["FT001"]);
|
||||
|
||||
const parsed2 = parseArgs(["workflow", "patch", "--in-place", "--value-json", "PIPE_123"]);
|
||||
expect(booleanOption(parsed2.options, ["in-place"])).toBe(true);
|
||||
expect(booleanOption(parsed2.options, ["value-json"])).toBe(true);
|
||||
expect(parsed2.args).toEqual(["PIPE_123"]);
|
||||
|
||||
const parsed3 = parseArgs(["platform", "record", "toggle", "--active", "false", "REC_01"]);
|
||||
expect(booleanOption(parsed3.options, ["active"], true)).toBe(false);
|
||||
expect(parsed3.args).toEqual(["toggle", "REC_01"]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user