Merge PR #8995: fix(cli): strip launch-global flags before non-launch subcommands (@roboomp)
This commit is contained in:
@@ -62,3 +62,33 @@ describe("resolveCliArgv routes subcommands hidden behind leading global flags",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveCliArgv strips launch-global flags before non-launch subcommands (#8891)", () => {
|
||||
test("`--cwd <dir> update` drops the inapplicable launch flag instead of forwarding it", () => {
|
||||
// Forwarding `--cwd` into update's strict parser crashed with
|
||||
// `Unknown option '--cwd'`; the launch-only flag is now dropped.
|
||||
expect(resolveCliArgv(["--cwd", "/tmp", "update"])).toEqual({ argv: ["update"] });
|
||||
});
|
||||
|
||||
test("`--cwd=<dir>` inline form is stripped too", () => {
|
||||
expect(resolveCliArgv(["--cwd=/tmp", "update"])).toEqual({ argv: ["update"] });
|
||||
});
|
||||
|
||||
test("a trailing subcommand flag survives while the leading launch flag is stripped", () => {
|
||||
expect(resolveCliArgv(["--cwd", "/tmp", "update", "--force"])).toEqual({
|
||||
argv: ["update", "--force"],
|
||||
});
|
||||
});
|
||||
|
||||
test("multiple leading launch flags are all stripped before a non-launch subcommand", () => {
|
||||
expect(resolveCliArgv(["--model", "gpt", "--cwd", "/x", "update"])).toEqual({ argv: ["update"] });
|
||||
});
|
||||
|
||||
test("a subcommand's own flag placed before it is kept, not treated as launch-global", () => {
|
||||
expect(resolveCliArgv(["-c", "update"])).toEqual({ argv: ["update", "-c"] });
|
||||
});
|
||||
|
||||
test("launch-shaped `acp` still receives forwarded launch-global flags", () => {
|
||||
expect(resolveCliArgv(["--cwd", "/x", "acp"])).toEqual({ argv: ["acp", "--cwd", "/x"] });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user