( question: string, defaultYes: boolean, opts: PromptOptions, )
| 15 | |
| 16 | /** Yes/no prompt. Default is the answer used in non-interactive mode and on bare Enter. */ |
| 17 | export async function confirm( |
| 18 | question: string, |
| 19 | defaultYes: boolean, |
| 20 | opts: PromptOptions, |
| 21 | ): Promise<boolean> { |
| 22 | if (!opts.interactive) return defaultYes; |
| 23 | const hint = defaultYes ? '[Y/n]' : '[y/N]'; |
| 24 | const ans = (await readLine(`${question} ${hint} `)).trim().toLowerCase(); |
| 25 | if (ans === '') return defaultYes; |
| 26 | return ans === 'y' || ans === 'yes'; |
| 27 | } |
| 28 | |
| 29 | /** Resolve the starting index for a select list from its default value. Pure → testable. */ |
| 30 | export function initialIndex<T extends string>( |
no test coverage detected