Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions src/sfCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,17 +336,7 @@ export abstract class SfCommand<T> extends Command {
* @return true if the user confirms, false if they do not.
*/
public async confirm(message: string, ms = 10000): Promise<boolean> {
const { confirmed } = await this.timedPrompt<{ confirmed: boolean }>(
[
{
name: 'confirmed',
message,
type: 'confirm',
},
],
ms
);
return confirmed;
return this.prompter.confirm(message, ms);
}

/**
Expand Down
21 changes: 21 additions & 0 deletions src/ux/prompter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> {
const { confirmed } = await this.timedPrompt<{ confirmed: boolean }>(
[
{
name: 'confirmed',
message,
type: 'confirm',
},
],
ms
);
return confirmed;
}
}

export namespace Prompter {
Expand Down