feat: improve ask flow elaboration and validation
This commit is contained in:
+13
-2
@@ -1,11 +1,22 @@
|
||||
import { CANCELLED_RESULT_TEXT, SUBMITTED_RESULT_TEXT } from "./constants.ts";
|
||||
import { formatResultLines } from "./result-format.ts";
|
||||
import {
|
||||
CANCELLED_RESULT_TEXT,
|
||||
ELABORATED_RESULT_TEXT,
|
||||
SUBMITTED_RESULT_TEXT,
|
||||
} from "./constants.ts";
|
||||
import { formatElaborationLines, formatResultLines } from "./result-format.ts";
|
||||
import type { AskResult } from "./types.ts";
|
||||
|
||||
export function renderResultText(result: AskResult): string {
|
||||
if (result.error) {
|
||||
return "Invalid input";
|
||||
}
|
||||
if (result.cancelled) {
|
||||
return CANCELLED_RESULT_TEXT;
|
||||
}
|
||||
if (result.mode === "elaborate") {
|
||||
const lines = formatElaborationLines(result, { mode: "render" });
|
||||
return lines.join("\n") || ELABORATED_RESULT_TEXT;
|
||||
}
|
||||
|
||||
const lines = formatResultLines(result, { mode: "render" });
|
||||
return lines.join("\n") || SUBMITTED_RESULT_TEXT;
|
||||
|
||||
Reference in New Issue
Block a user