Skip to content

Commit

Permalink
feat: simplified confirm prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Mar 16, 2022
1 parent d6ddb89 commit ddf1364
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/ux/prompter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> {
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.
*/
Expand Down

0 comments on commit ddf1364

Please sign in to comment.