Implement app info action

This commit is contained in:
Juan Cruz Viotti 2014-11-19 09:23:40 -04:00
parent 3015af3aeb
commit 77d84103f6
3 changed files with 29 additions and 1 deletions

View File

@ -6,7 +6,6 @@ applicationModel = require('../models/application')
authHooks = require('../hooks/auth')
exports.list = authHooks.failIfNotLoggedIn ->
applicationModel.getAll().then (applications) ->
applications = _.map applications, (application) ->
@ -19,3 +18,15 @@ exports.list = authHooks.failIfNotLoggedIn ->
}
console.log cliff.stringifyObjectRows(applications, _.keys _.first applications)
exports.info = authHooks.failIfNotLoggedIn (id) ->
applicationModel.get(id).then (application) ->
console.log("ID: #{application.id}")
console.log("Name: #{application.app_name}")
console.log("Device Type: #{device.getDisplayName(application.device_type)}")
console.log("Git Repository: #{application.git_repository}")
console.log("Commit: #{application.commit}")
.catch (error) ->
throw error

View File

@ -33,6 +33,11 @@ program
.description('Show a list of your apps')
.action(app.list)
program
.command('app <id>')
.description('Show an application')
.action(app.info)
# ---------- Preferences Module ----------
preferences = require('./actions/preferences')

View File

@ -1,3 +1,4 @@
Promise = require('bluebird')
canvas = require('./_canvas')
exports.getAll = ->
@ -6,3 +7,14 @@ exports.getAll = ->
options:
orderby: 'app_name asc'
expand: 'device'
exports.get = (id) ->
return canvas.get
resource: 'application'
id: id
.then (application) ->
if not application?
Promise.reject(new Error('Not found'))
return application