From 9c89ee99901c7abefc11a811e8e4dda0c704ed1c Mon Sep 17 00:00:00 2001 From: mshanemc Date: Wed, 16 Mar 2022 11:03:31 -0500 Subject: [PATCH] feat: confirms are timed --- src/sfCommand.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/sfCommand.ts b/src/sfCommand.ts index 8f8d2648..828f89e5 100644 --- a/src/sfCommand.ts +++ b/src/sfCommand.ts @@ -167,16 +167,20 @@ export abstract class SfCommand extends Command { * 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): Promise { - const { confirmed } = await this.prompt<{ confirmed: boolean }>([ - { - name: 'confirmed', - message, - type: 'confirm', - }, - ]); + public async confirm(message: string, ms = 10000): Promise { + const { confirmed } = await this.timedPrompt<{ confirmed: boolean }>( + [ + { + name: 'confirmed', + message, + type: 'confirm', + }, + ], + ms + ); return confirmed; }