MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / choose

Function choose

src/setup/prompt.ts:71–82  ·  view source on GitHub ↗
(
  question: string,
  options: Array<{ value: T; label: string; hint?: string }>,
  defaultValue: T,
  opts: PromptOptions,
)

Source from the content-addressed store, hash-verified

69 * Non-raw terminals / pipes → falls back to the numbered prompt (no regression).
70 */
71export async function choose<T extends string>(
72 question: string,
73 options: Array<{ value: T; label: string; hint?: string }>,
74 defaultValue: T,
75 opts: PromptOptions,
76): Promise<T> {
77 if (!opts.interactive) return defaultValue;
78 const canRaw = typeof (process.stdin as any).setRawMode === 'function' && process.stdin.isTTY;
79 return canRaw
80 ? chooseInteractive(question, options, defaultValue)
81 : chooseNumbered(question, options, defaultValue);
82}
83
84/** Arrow-key driven selector. Redraws the list in place as the highlight moves. */
85function chooseInteractive<T extends string>(

Callers 2

interactiveAddProviderFunction · 0.85

Calls 2

chooseInteractiveFunction · 0.85
chooseNumberedFunction · 0.85

Tested by

no test coverage detected