diff --git a/lib/actions/app.coffee b/lib/actions/app.coffee index 80dd1ff3..e4b33c46 100644 --- a/lib/actions/app.coffee +++ b/lib/actions/app.coffee @@ -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) diff --git a/package.json b/package.json index 8a95c388..c764449a 100644 --- a/package.json +++ b/package.json @@ -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" } }