refactor(cli): share styled select prompt helper

This commit is contained in:
Peter Steinberger
2026-02-18 17:34:38 +00:00
parent 8b48e0c615
commit 005e1d5fd1
4 changed files with 68 additions and 22 deletions

View File

@@ -1,9 +1,10 @@
import { cancel, confirm, isCancel, select } from "@clack/prompts";
import { cancel, confirm, isCancel } from "@clack/prompts";
import { formatCliCommand } from "../cli/command-format.js";
import { isNixMode } from "../config/config.js";
import { resolveGatewayService } from "../daemon/service.js";
import type { RuntimeEnv } from "../runtime.js";
import { stylePromptHint, stylePromptMessage, stylePromptTitle } from "../terminal/prompt-style.js";
import { selectStyled } from "../terminal/prompt-select-styled.js";
import { stylePromptMessage, stylePromptTitle } from "../terminal/prompt-style.js";
import { resolveCleanupPlanFromDisk } from "./cleanup-plan.js";
import { listAgentSessionDirs, removePath } from "./cleanup-utils.js";
@@ -16,15 +17,6 @@ export type ResetOptions = {
dryRun?: boolean;
};
const selectStyled = <T>(params: Parameters<typeof select<T>>[0]) =>
select({
...params,
message: stylePromptMessage(params.message),
options: params.options.map((opt) =>
opt.hint === undefined ? opt : { ...opt, hint: stylePromptHint(opt.hint) },
),
});
async function stopGatewayIfRunning(runtime: RuntimeEnv) {
if (isNixMode) {
return;