refactor: dedupe cli lowercase helpers

This commit is contained in:
Peter Steinberger
2026-04-07 17:35:58 +01:00
parent cebfa70277
commit 1a3f141215
28 changed files with 96 additions and 63 deletions

View File

@@ -9,6 +9,7 @@ import {
type PairingChannel,
} from "../pairing/pairing-store.js";
import { defaultRuntime } from "../runtime.js";
import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";
import { formatDocsLink } from "../terminal/links.js";
import { getTerminalTableWidth, renderTable } from "../terminal/table.js";
import { theme } from "../terminal/theme.js";
@@ -16,15 +17,14 @@ import { formatCliCommand } from "./command-format.js";
/** Parse channel, allowing extension channels not in core registry. */
function parseChannel(raw: unknown, channels: PairingChannel[]): PairingChannel {
const value = (
typeof raw === "string"
const value = normalizeLowercaseStringOrEmpty(
(typeof raw === "string"
? raw
: typeof raw === "number" || typeof raw === "boolean"
? String(raw)
: ""
)
.trim()
.toLowerCase();
).trim(),
);
if (!value) {
throw new Error("Channel required");
}