diff --git a/src/sfCommand.ts b/src/sfCommand.ts index e93b27d63..a7534018f 100644 --- a/src/sfCommand.ts +++ b/src/sfCommand.ts @@ -336,17 +336,7 @@ export abstract class SfCommand extends Command { * @return true if the user confirms, false if they do not. */ public async confirm(message: string, ms = 10000): Promise { - const { confirmed } = await this.timedPrompt<{ confirmed: boolean }>( - [ - { - name: 'confirmed', - message, - type: 'confirm', - }, - ], - ms - ); - return confirmed; + return this.prompter.confirm(message, ms); } /** diff --git a/src/ux/prompter.ts b/src/ux/prompter.ts index 85a2b847d..3f21bf034 100644 --- a/src/ux/prompter.ts +++ b/src/ux/prompter.ts @@ -49,6 +49,27 @@ export class Prompter { return result as T; }); } + + /** + * Simplified prompt for single-question confirmation. Times out and throws after 10s + * + * @param message text to display. Do not include a question mark. + * @param ms milliseconds to wait for user input. Defaults to 10s. + * @return true if the user confirms, false if they do not. + */ + public async confirm(message: string, ms = 10000): Promise { + const { confirmed } = await this.timedPrompt<{ confirmed: boolean }>( + [ + { + name: 'confirmed', + message, + type: 'confirm', + }, + ], + ms + ); + return confirmed; + } } export namespace Prompter {