Add non interactive support for app:create

This commit is contained in:
Juan Cruz Viotti 2014-11-24 10:56:03 -04:00
parent f4ad73d2f8
commit f0e25589cd
2 changed files with 13 additions and 3 deletions

View File

@ -10,15 +10,24 @@ applicationModel = require('../models/application')
authHooks = require('../hooks/auth')
config = require('../config')
exports.create = authHooks.failIfNotLoggedIn (name) ->
exports.create = authHooks.failIfNotLoggedIn (name, program) ->
async.waterfall [
(callback) ->
deviceTypes = device.getSupportedDevices()
widgets.select('Select a type', deviceTypes, callback)
deviceType = program.parent.type
if deviceType?
return callback(null, deviceType)
else
deviceTypes = device.getSupportedDevices()
widgets.select('Select a type', deviceTypes, callback)
(type, callback) ->
# TODO: Currently returns 'unknown'.
# Maybe we should break or handle better?
slugifiedType = device.getDeviceSlug(type)
applicationModel.create(name, slugifiedType).then ->
return callback()
.catch(callback)

View File

@ -9,6 +9,7 @@ program.version(packageJSON.version)
# ---------- Options ----------
program.option('-y, --yes', 'Confirm non interactively')
program.option('-q, --quiet', 'quiet (no output)')
program.option('-t, --type <type>', 'specify a type when creating an application')
# ---------- Auth Module ----------
auth = require('./actions/auth')