diff --git a/src/ux/prompter.ts b/src/ux/prompter.ts index 8348b72a..82587aa1 100644 --- a/src/ux/prompter.ts +++ b/src/ux/prompter.ts @@ -18,6 +18,23 @@ export class Prompter { return answers; } + /** + * Simplified prompt for single-question confirmation. Times out and throws after 10s + * + * @param message text to display. Do not include a question mark. + * @return true if the user confirms, false if they do not. + */ + public async confirm(message: string): Promise { + const { confirmed } = await this.prompt<{ confirmed: boolean }>([ + { + name: 'confirmed', + message, + type: 'confirm', + }, + ]); + return confirmed; + } + /** * Prompt user for information with a timeout (in milliseconds). See https://www.npmjs.com/package/inquirer for more. */