fix(cli): improve terminal error guidance

This commit is contained in:
Vincent Koc
2026-05-10 09:57:20 +08:00
parent 6811ef058b
commit be1c38e692
23 changed files with 178 additions and 50 deletions

View File

@@ -34,6 +34,7 @@ import {
parsePort,
resolveRuntimeStatusColor,
} from "../daemon-cli/shared.js";
import { formatInvalidConfigPort, formatInvalidPortOption } from "../error-format.js";
type NodeDaemonInstallOptions = {
host?: string;
@@ -95,7 +96,11 @@ export async function runNodeDaemonInstall(opts: NodeDaemonInstallOptions) {
const config = await loadNodeHostConfig();
const { host, port } = resolveNodeDefaults(opts, config);
if (!Number.isFinite(port ?? Number.NaN) || (port ?? 0) <= 0 || (port ?? 0) > 65_535) {
fail("Invalid node host port. Use a port number from 1 to 65535.");
fail(
opts.port !== undefined
? formatInvalidPortOption("--port")
: formatInvalidConfigPort("node.gateway.port"),
);
return;
}