A simple Node tool to have Browser's confirm
popup on your CLI.
yarn add confirmation
In an async
function just call await confirmation
.
if (await confirmation('Are you sure?')) {
console.log('Yay!');
} else {
console.log('Oops!');
}
Shows a message and OK
and Cancel
buttons.
Example:
const result = await confirmation('You will delete your items, are you sure?')
Shows a message with a title and OK
and Cancel
buttons.
Example:
const result = await confirmation('Warning', 'You will delete your items, are you sure?')
Shows a message with a title and custom OK
and custom Cancel
buttons.
Example:
const result = await confirmation(
'Warning',
'You will delete your items, are you sure?',
'I am sure',
'No!'
)
The Y for OK and N for Cancel are the default key bindings.
When you customize your OK and Cancel buttons, the first letter will be the key binding. If you make I am Sure instead of OK, you'll need to press I to confirm.
Example:
const result = await confirmation(
'Warning',
'You will delete your items, are you sure?',
'[O] OK',
'[X] Close'
)
Keymap:
- O to Confirm
- X to Close
Example:
const result = await confirmation(
'Warnin\'',
'Ye will scuttle yer items, are ye sure?',
'Aye',
'No'
)
Keymap:
- A (_A_ye) to Confirm
- N (_N_o) to Close
MIT © Fatih Kadir Akin