diff --git a/apps/t3/src/cli.test.ts b/apps/t3/src/cli.test.ts index 26bd846238..03799ab44f 100644 --- a/apps/t3/src/cli.test.ts +++ b/apps/t3/src/cli.test.ts @@ -92,6 +92,14 @@ describe("parseCliOptions", () => { expect(options.noOpen).toBe(false); }); + it("supports equals-style -o boolean values", () => { + const enabled = parseCliOptions(["-o=true"], { T3_NO_OPEN: "true" }, "/workspace"); + expect(enabled.noOpen).toBe(false); + + const disabled = parseCliOptions(["-o=0"], { T3_NO_OPEN: "false" }, "/workspace"); + expect(disabled.noOpen).toBe(true); + }); + it("supports explicit equals-style --open boolean overrides", () => { const options = parseCliOptions( ["--open=false"], @@ -162,6 +170,12 @@ describe("parseCliOptions", () => { ); }); + it("throws for invalid equals-style -o values", () => { + expect(() => parseCliOptions(["-o=maybe"], {}, "/workspace")).toThrow( + "Invalid value for -o", + ); + }); + it("throws for empty equals-style --open values", () => { expect(() => parseCliOptions(["--open="], {}, "/workspace")).toThrow( "Invalid value for --open", @@ -468,6 +482,12 @@ describe("parseCliOptions", () => { ); }); + it("treats -o=bool after --backend-port as missing value", () => { + expect(() => parseCliOptions(["--backend-port", "-o=true"], {}, "/workspace")).toThrow( + "Missing value for --backend-port", + ); + }); + it("treats equals-style flag tokens after --backend-port as missing values", () => { expect(() => parseCliOptions(["--backend-port", "--web-port=7000"], {}, "/workspace"), @@ -645,6 +665,12 @@ describe("parseCliOptions", () => { ); }); + it("treats -o=bool after --cwd as missing value", () => { + expect(() => parseCliOptions(["--cwd", "-o=false"], {}, "/workspace")).toThrow( + "Missing value for --cwd", + ); + }); + it("treats end-of-options marker after --cwd as missing value", () => { expect(() => parseCliOptions(["--cwd", "--"], {}, "/workspace")).toThrow( "Missing value for --cwd", diff --git a/apps/t3/src/cli.ts b/apps/t3/src/cli.ts index 6c9d39fd2b..ad6955e89f 100644 --- a/apps/t3/src/cli.ts +++ b/apps/t3/src/cli.ts @@ -116,7 +116,7 @@ function isKnownFlagToken(value: string): boolean { } for (const flag of KNOWN_CLI_FLAGS) { - if (!flag.startsWith("--") || flag === "--") { + if (flag === "--") { continue; } if (value.startsWith(`${flag}=`)) { @@ -235,6 +235,11 @@ export function parseCliOptions( continue; } + if (arg.startsWith("-o=")) { + noOpen = !parseBooleanCliValue(arg.split("=")[1] ?? "", "-o"); + continue; + } + if (arg.startsWith("--open=")) { noOpen = !parseBooleanCliValue(arg.split("=")[1] ?? "", "--open"); continue;