MCPcopy Index your code
hub / github.com/bombshell-dev/clack / group

Function group

packages/prompts/src/group.ts:60–86  ·  view source on GitHub ↗
(
	prompts: PromptGroup<T>,
	opts?: PromptGroupOptions<T>
)

Source from the content-addressed store, hash-verified

58 * ```
59 */
60export const group = async <T>(
61 prompts: PromptGroup<T>,
62 opts?: PromptGroupOptions<T>
63): Promise<Prettify<PromptGroupAwaitedReturn<T>>> => {
64 const results = {} as any;
65 const promptNames = Object.keys(prompts);
66
67 for (const name of promptNames) {
68 const prompt = prompts[name as keyof T];
69 const result = await prompt({ results })?.catch((e) => {
70 throw e;
71 });
72
73 // Pass the results to the onCancel function
74 // so the user can decide what to do with the results
75 // TODO: Switch to callback within core to avoid isCancel Fn
76 if (typeof opts?.onCancel === 'function' && isCancel(result)) {
77 results[name] = 'canceled';
78 opts.onCancel({ results });
79 continue;
80 }
81
82 results[name] = result;
83 }
84
85 return results;
86};

Callers

nothing calls this directly

Calls 1

isCancelFunction · 0.90

Tested by

no test coverage detected