From d943f75b7c3fea26ce2cc6038fb1f29aed96f644 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 10 Feb 2026 01:46:49 +0000 Subject: [PATCH] Support equals-style boolean values for --no-open Co-authored-by: Theo Browne --- README.md | 2 +- apps/t3/src/cli.test.ts | 22 ++++++++++++++++++++++ apps/t3/src/cli.ts | 21 ++++++++++++++++++++- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0ba04557f0..b42cf864ab 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ On launch, `t3`: CLI flags: -- `--no-open` — do not open a browser window automatically. +- `--no-open[=bool]` — disable browser auto-open (supports `true/false`, `1/0`, `yes/no`, `on/off` in equals form). - `--backend-port ` — set WebSocket runtime port. - `--web-port ` — set web UI port. - `--cwd ` — choose launch project directory (defaults to current directory). diff --git a/apps/t3/src/cli.test.ts b/apps/t3/src/cli.test.ts index fca42bcfcd..c04e8cd9e4 100644 --- a/apps/t3/src/cli.test.ts +++ b/apps/t3/src/cli.test.ts @@ -59,6 +59,28 @@ describe("parseCliOptions", () => { expect(options.noOpen).toBe(true); }); + it("supports explicit equals-style --no-open boolean overrides", () => { + const options = parseCliOptions( + ["--no-open=false"], + { + T3_NO_OPEN: "true", + }, + "/workspace", + ); + expect(options.noOpen).toBe(false); + }); + + it("supports falsey equals-style --no-open values", () => { + const options = parseCliOptions(["--no-open=0"], {}, "/workspace"); + expect(options.noOpen).toBe(false); + }); + + it("throws for invalid equals-style --no-open values", () => { + expect(() => parseCliOptions(["--no-open=maybe"], {}, "/workspace")).toThrow( + "Invalid value for --no-open", + ); + }); + it("parses case-insensitive and trimmed T3_NO_OPEN truthy values", () => { const options = parseCliOptions( [], diff --git a/apps/t3/src/cli.ts b/apps/t3/src/cli.ts index 0bdc264c5c..28ecaaa700 100644 --- a/apps/t3/src/cli.ts +++ b/apps/t3/src/cli.ts @@ -63,6 +63,20 @@ function parseBooleanEnvFlag(value: string | undefined): boolean { return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on"; } +function parseBooleanCliValue(value: string, key: string): boolean { + const normalized = value.trim().toLowerCase(); + if (normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on") { + return true; + } + if (normalized === "0" || normalized === "false" || normalized === "no" || normalized === "off") { + return false; + } + + throw new Error( + `Invalid value for ${key}: '${value}'. Expected one of true/false, 1/0, yes/no, on/off.`, + ); +} + interface CliOptions { backendPort: number; webPort: number; @@ -194,6 +208,11 @@ export function parseCliOptions( continue; } + if (arg.startsWith("--no-open=")) { + noOpen = parseBooleanCliValue(arg.split("=")[1] ?? "", "--no-open"); + continue; + } + if (arg.startsWith("--backend-port=")) { backendPort = parseExplicitPort(arg.split("=")[1] ?? "", "--backend-port"); backendPortLocked = true; @@ -271,7 +290,7 @@ function printHelp(): void { "Usage: t3 [options]", "", "Options:", - " --no-open Start runtime without opening browser", + " --no-open[=bool] Start runtime without opening browser (or explicitly set bool)", " --backend-port Override WebSocket API port (default: 4317)", " --web-port Override web UI port (default: 4318)", " --cwd Launch project directory (default: current directory)",