balena-cli/lib/utils/helpers.coffee
Juan Cruz Viotti 354921ca92 Add Aborted error message when not accepting a confirmation
This prevents a lot of duplicate code to check for confirmation status
and exit from the current action.
2015-08-20 16:16:20 -04:00

27 lines
541 B
CoffeeScript

Promise = require('bluebird')
form = require('resin-cli-form')
exports.selectDeviceType = ->
return form.ask
message: 'Device Type'
type: 'list'
choices: [
# Lock to specific devices until we support
# the rest with device specs.
'Raspberry Pi'
'Raspberry Pi 2'
'BeagleBone Black'
]
exports.confirm = (yesOption, message) ->
Promise.try ->
return true if yesOption
return form.ask
message: message
type: 'confirm'
default: false
.then (confirmed) ->
if not confirmed
throw new Error('Aborted')