Improve apps printing with cliff

This commit is contained in:
Juan Cruz Viotti 2014-11-18 14:39:26 -04:00
parent 8777bb9536
commit 89ec171a3d
2 changed files with 15 additions and 3 deletions

View File

@ -1,3 +1,5 @@
_ = require('lodash')
cliff = require('cliff')
server = require('../server/server')
applicationModel = require('../models/application')
authHooks = require('../hooks/auth')
@ -5,5 +7,14 @@ authHooks = require('../hooks/auth')
exports.list = authHooks.failIfNotLoggedIn ->
applicationModel.getAll().then (applications) ->
for app in applications
console.log "#{app.id} - #{app.app_name}"
applications = _.map applications, (application) ->
return {
ID: application.id
Name: application.app_name
'Device Type': application.device_type
'Online Devices': _.where(application.device, is_online: 1).length
'All Devices': application.device?.length or 0
}
console.log cliff.stringifyObjectRows(applications, _.keys _.first applications)

View File

@ -35,6 +35,7 @@
"resin-platform-api": "git+ssh://git@bitbucket.org/rulemotion/resin-platform-api.git#master",
"bluebird": "~2.3.11",
"open": "0.0.5",
"inquirer": "~0.8.0"
"inquirer": "~0.8.0",
"cliff": "~0.1.9"
}
}