(
question: string,
options: Array<{ value: T; label: string; hint?: string }>,
defaultValue: T,
opts: PromptOptions,
)
| 69 | * Non-raw terminals / pipes → falls back to the numbered prompt (no regression). |
| 70 | */ |
| 71 | export 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. */ |
| 85 | function chooseInteractive<T extends string>( |
no test coverage detected