refactor(cli): dedupe configure section parsing

This commit is contained in:
Peter Steinberger
2026-02-15 04:42:00 +00:00
parent b5c81f732c
commit ae599243fd
4 changed files with 32 additions and 15 deletions

View File

@@ -3,6 +3,7 @@ import {
CONFIGURE_WIZARD_SECTIONS,
configureCommand,
configureCommandWithSections,
parseConfigureWizardSections,
} from "../../commands/configure.js";
import { defaultRuntime } from "../../runtime.js";
import { formatDocsLink } from "../../terminal/links.js";
@@ -26,17 +27,12 @@ export function registerConfigureCommand(program: Command) {
)
.action(async (opts) => {
await runCommandWithRuntime(defaultRuntime, async () => {
const sections: string[] = Array.isArray(opts.section)
? opts.section
.map((value: unknown) => (typeof value === "string" ? value.trim() : ""))
.filter(Boolean)
: [];
const { sections, invalid } = parseConfigureWizardSections(opts.section);
if (sections.length === 0) {
await configureCommand(defaultRuntime);
return;
}
const invalid = sections.filter((s) => !CONFIGURE_WIZARD_SECTIONS.includes(s as never));
if (invalid.length > 0) {
defaultRuntime.error(
`Invalid --section: ${invalid.join(", ")}. Expected one of: ${CONFIGURE_WIZARD_SECTIONS.join(", ")}.`,