feat: loop configure section picker

This commit is contained in:
Peter Steinberger
2026-01-12 05:48:42 +00:00
parent 0f257f792a
commit 744fadbded

View File

@@ -155,41 +155,33 @@ async function promptConfigureSections(
runtime: RuntimeEnv, runtime: RuntimeEnv,
): Promise<WizardSection[]> { ): Promise<WizardSection[]> {
const selected: WizardSection[] = []; const selected: WizardSection[] = [];
let remaining = CONFIGURE_SECTION_OPTIONS.slice(); const continueValue = "__continue";
let addMore = true;
while (addMore && remaining.length > 0) { while (true) {
const choice = guardCancel( const choice = guardCancel(
await select<WizardSection>({ await select<string>({
message: message: "Select sections to configure",
selected.length === 0 options: [
? "Select a section to configure" ...CONFIGURE_SECTION_OPTIONS,
: "Select another section to configure", {
options: remaining, value: continueValue,
initialValue: remaining[0]?.value, label: "Continue",
hint: selected.length === 0 ? "Skip for now" : "Run selected",
},
],
initialValue: CONFIGURE_SECTION_OPTIONS[0]?.value,
}), }),
runtime, runtime,
) as WizardSection;
if (!selected.includes(choice)) {
selected.push(choice);
}
remaining = CONFIGURE_SECTION_OPTIONS.filter(
(option) => !selected.includes(option.value),
); );
if (remaining.length === 0) { if (choice === continueValue) {
break; break;
} }
addMore = guardCancel( const section = choice as WizardSection;
await confirm({ if (!selected.includes(section)) {
message: "Configure another section?", selected.push(section);
initialValue: false, }
}),
runtime,
);
} }
return selected; return selected;