MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / createNonInteractivePrompter

Function createNonInteractivePrompter

src/cli/interactive/prompts.ts:30–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28}
29
30function createNonInteractivePrompter(): Prompter {
31 return {
32 async selectOne<T>(opts: { options: SelectOption<T>[]; initialIndex?: number }): Promise<T> {
33 if (opts.options.length === 0) {
34 throw new Error('No options available for selection.');
35 }
36 const index = clampIndex(opts.initialIndex ?? 0, opts.options.length);
37 return opts.options[index].value;
38 },
39 async selectMany<T>(opts: {
40 options: SelectOption<T>[];
41 initialSelectedKeys?: ReadonlySet<string>;
42 getKey: (value: T) => string;
43 minSelected?: number;
44 }): Promise<T[]> {
45 const selected = opts.options.filter((option) =>
46 (opts.initialSelectedKeys ?? new Set<string>()).has(opts.getKey(option.value)),
47 );
48 if (selected.length > 0) {
49 return selected.map((option) => option.value);
50 }
51
52 const minSelected = opts.minSelected ?? 0;
53 return opts.options.slice(0, minSelected).map((option) => option.value);
54 },
55 async confirm(opts: { defaultValue: boolean }): Promise<boolean> {
56 return opts.defaultValue;
57 },
58 };
59}
60
61function handleCancel(result: unknown): void {
62 if (clack.isCancel(result)) {

Callers 1

createPrompterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected