From f0e25589cd08ef334f5e89bb30b7da08d08b48fb Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 24 Nov 2014 10:56:03 -0400 Subject: [PATCH] Add non interactive support for app:create --- lib/actions/app.coffee | 15 ++++++++++++--- lib/app.coffee | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/actions/app.coffee b/lib/actions/app.coffee index 71fb3bcc..1f149875 100644 --- a/lib/actions/app.coffee +++ b/lib/actions/app.coffee @@ -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) diff --git a/lib/app.coffee b/lib/app.coffee index 92452036..7d441586 100644 --- a/lib/app.coffee +++ b/lib/app.coffee @@ -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 ', 'specify a type when creating an application') # ---------- Auth Module ---------- auth = require('./actions/auth')