From be2136365433f41f04de0612777143fe19de354b Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 10 Feb 2026 00:53:19 +0000 Subject: [PATCH] Support -- end-of-options path parsing Co-authored-by: Theo Browne --- apps/t3/src/cli.test.ts | 15 +++++++++++++++ apps/t3/src/cli.ts | 17 +++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/apps/t3/src/cli.test.ts b/apps/t3/src/cli.test.ts index d5d8735d99..25a1817f8c 100644 --- a/apps/t3/src/cli.test.ts +++ b/apps/t3/src/cli.test.ts @@ -145,6 +145,21 @@ describe("parseCliOptions", () => { ); }); + it("supports end-of-options marker for positional cwd values", () => { + const options = parseCliOptions(["--", "-project"], {}, "/workspace"); + expect(options.launchCwd).toBe(path.resolve("/workspace", "-project")); + }); + + it("throws when end-of-options marker has no positional value", () => { + expect(() => parseCliOptions(["--"], {}, "/workspace")).toThrow("Missing value for [path]"); + }); + + it("throws when end-of-options marker has multiple positional values", () => { + expect(() => parseCliOptions(["--", "apps/renderer", "apps/t3"], {}, "/workspace")).toThrow( + "Unexpected positional argument: apps/t3", + ); + }); + it("keeps ports unlocked when using defaults", () => { const options = parseCliOptions([], {}, "/workspace"); expect(options.backendPortLocked).toBe(false); diff --git a/apps/t3/src/cli.ts b/apps/t3/src/cli.ts index 86d4b2ca89..2966bfbc78 100644 --- a/apps/t3/src/cli.ts +++ b/apps/t3/src/cli.ts @@ -131,6 +131,23 @@ export function parseCliOptions( const arg = argv[index]; if (!arg) continue; + if (arg === "--") { + const positionalArgs = argv.slice(index + 1); + const [first, ...rest] = positionalArgs; + if (!first) { + throw new Error("Missing value for [path]."); + } + if (usedPositionalCwd) { + throw new Error(`Unexpected positional argument: ${first}`); + } + if (rest.length > 0) { + throw new Error(`Unexpected positional argument: ${rest[0]}`); + } + launchCwd = parseExplicitPath(first, "[path]", parserCwd); + usedPositionalCwd = true; + break; + } + if (arg === "--help" || arg === "-h") { showHelp = true; continue;