From ddf1364a48fb384bd0ad66bc310a35abcef20d68 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Wed, 16 Mar 2022 09:30:20 -0500 Subject: [PATCH] feat: simplified confirm prompts --- src/ux/prompter.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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. */