diff --git a/apps/t3/src/cli.test.ts b/apps/t3/src/cli.test.ts index 47d0eab87b..beb0d881be 100644 --- a/apps/t3/src/cli.test.ts +++ b/apps/t3/src/cli.test.ts @@ -378,6 +378,12 @@ describe("parseCliOptions", () => { ); }); + it("treats equals-style flag tokens after --backend-port as missing values", () => { + expect(() => + parseCliOptions(["--backend-port", "--web-port=7000"], {}, "/workspace"), + ).toThrow("Missing value for --backend-port"); + }); + it("treats end-of-options marker after --backend-port as missing value", () => { expect(() => parseCliOptions(["--backend-port", "--"], {}, "/workspace")).toThrow( "Missing value for --backend-port", @@ -402,6 +408,12 @@ describe("parseCliOptions", () => { ); }); + it("treats equals-style flag tokens after --web-port as missing values", () => { + expect(() => + parseCliOptions(["--web-port", "--backend-port=7000"], {}, "/workspace"), + ).toThrow("Missing value for --web-port"); + }); + it("treats end-of-options marker after --web-port as missing value", () => { expect(() => parseCliOptions(["--web-port", "--"], {}, "/workspace")).toThrow( "Missing value for --web-port", @@ -501,6 +513,12 @@ describe("parseCliOptions", () => { ); }); + it("treats equals-style flag tokens after --cwd as missing values", () => { + expect(() => parseCliOptions(["--cwd", "--open=false"], {}, "/workspace")).toThrow( + "Missing value for --cwd", + ); + }); + it("treats --open after --cwd as missing value", () => { expect(() => parseCliOptions(["--cwd", "--open"], {}, "/workspace")).toThrow( "Missing value for --cwd", diff --git a/apps/t3/src/cli.ts b/apps/t3/src/cli.ts index abdea8c4b0..a52228409a 100644 --- a/apps/t3/src/cli.ts +++ b/apps/t3/src/cli.ts @@ -108,6 +108,23 @@ const KNOWN_CLI_FLAGS = new Set([ "--", ]); +function isKnownFlagToken(value: string): boolean { + if (KNOWN_CLI_FLAGS.has(value)) { + return true; + } + + for (const flag of KNOWN_CLI_FLAGS) { + if (!flag.startsWith("--") || flag === "--") { + continue; + } + if (value.startsWith(`${flag}=`)) { + return true; + } + } + + return false; +} + function readArgValue( args: string[], index: number, @@ -125,7 +142,7 @@ function readArgValue( if (!options?.allowDashPrefixed && dashPrefixed) { throw new Error(`Missing value for ${key}.`); } - if (options?.allowDashPrefixed && dashPrefixed && KNOWN_CLI_FLAGS.has(value)) { + if (options?.allowDashPrefixed && dashPrefixed && isKnownFlagToken(value)) { throw new Error(`Missing value for ${key}.`); }