Skip to content

Commit

Permalink
feat: confirms are timed
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Mar 16, 2022
1 parent 84ce6da commit 9c89ee9
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/sfCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,20 @@ export abstract class SfCommand<T> 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<boolean> {
const { confirmed } = await this.prompt<{ confirmed: boolean }>([
{
name: 'confirmed',
message,
type: 'confirm',
},
]);
public async confirm(message: string, ms = 10000): Promise<boolean> {
const { confirmed } = await this.timedPrompt<{ confirmed: boolean }>(
[
{
name: 'confirmed',
message,
type: 'confirm',
},
],
ms
);
return confirmed;
}

Expand Down

0 comments on commit 9c89ee9

Please sign in to comment.