Support equals-style boolean values for --no-open

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-10 01:46:49 +00:00
1 parent 2c3789dd40
commit d943f75b7c
3 files changed
+43 -2

No files matched your search

+1 -1
View File
@@ -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 <port>` — set WebSocket runtime port.
- `--web-port <port>` — set web UI port.
- `--cwd <path>` — choose launch project directory (defaults to current directory).
+22
View File
@@ -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(
[],
+20 -1
View File
@@ -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 <port> Override WebSocket API port (default: 4317)",
" --web-port <port> Override web UI port (default: 4318)",
" --cwd <path> Launch project directory (default: current directory)",