MCPcopy Create free account
hub / github.com/cortexkit/magic-context / text

Function text

packages/cli/src/lib/prompts.ts:142–164  ·  view source on GitHub ↗
(
    message: string,
    options: {
        placeholder?: string;
        initialValue?: string;
        validate?: (value: string) => string | undefined;
    } = {},
)

Source from the content-addressed store, hash-verified

140}
141
142export async function text(
143 message: string,
144 options: {
145 placeholder?: string;
146 initialValue?: string;
147 validate?: (value: string) => string | undefined;
148 } = {},
149): Promise<string> {
150 const result = await clackText({
151 message,
152 placeholder: options.placeholder,
153 initialValue: options.initialValue,
154 validate: options.validate
155 ? (value) => {
156 const str = typeof value === "string" ? value : "";
157 const err = options.validate?.(str);
158 return err ?? undefined;
159 }
160 : undefined,
161 });
162 handleCancel(result);
163 return result as string;
164}
165
166// Clack's Option<T> is a distributed conditional that resolves differently
167// for primitive vs object values; the structural shape we build is correct

Callers 1

runIssueFlowFunction · 0.90

Calls 1

handleCancelFunction · 0.85

Tested by

no test coverage detected