MCPcopy
hub / github.com/continuedev/continue / questionWithChoices

Function questionWithChoices

extensions/cli/src/util/prompt.ts:36–60  ·  view source on GitHub ↗
(
  prompt: string,
  choices: string[],
  defaultChoice?: string,
  limitMessage?: string,
)

Source from the content-addressed store, hash-verified

34 * @param limitMessage Message to show when invalid choice is entered
35 */
36export async function questionWithChoices(
37 prompt: string,
38 choices: string[],
39 defaultChoice?: string,
40 limitMessage?: string,
41): Promise<string> {
42 while (true) {
43 const answer = await question(prompt);
44
45 // Handle default choice
46 if (answer === "" && defaultChoice !== undefined) {
47 return defaultChoice;
48 }
49
50 // Check if answer is valid
51 if (choices.includes(answer)) {
52 return answer;
53 }
54
55 // Show limit message if provided
56 if (limitMessage) {
57 console.log(limitMessage);
58 }
59 }
60}

Callers 1

prompt.test.tsFile · 0.85

Calls 2

questionFunction · 0.85
logMethod · 0.65

Tested by

no test coverage detected