balena-cli/lib/app.coffee

143 lines
3.2 KiB
CoffeeScript
Raw Normal View History

2014-11-24 12:12:12 -04:00
_ = require('lodash')
2014-11-26 12:38:02 -04:00
resin = require('./resin')
2014-11-21 09:23:02 -04:00
packageJSON = require('../package.json')
actions = require('./actions')
pluginLoader = require('./plugin-loader/plugin-loader')
2014-12-05 11:51:52 -04:00
cli = require('./cli/cli')
2014-11-17 15:48:26 -04:00
2014-12-05 11:51:52 -04:00
cli.setVersion(packageJSON.version)
2014-11-20 12:05:50 -04:00
# ---------- Options ----------
2014-12-05 11:51:52 -04:00
cli.addOption
option: '-y, --yes'
description: 'confirm non interactively'
2014-12-05 11:51:52 -04:00
cli.addOption
option: '-v, --verbose'
description: 'increase verbosity'
2014-12-05 11:51:52 -04:00
cli.addOption
option: '-q, --quiet'
description: 'quiet (no output)'
2014-12-05 11:51:52 -04:00
cli.addOption
option: '-t, --type <type>'
description: 'specify a type when creating an application'
2014-12-05 11:51:52 -04:00
cli.addOption
2014-11-28 20:18:59 -04:00
option: '-n, --num <num>'
description: 'number of lines to display'
2014-12-05 11:51:52 -04:00
cli.addOption
2014-11-28 20:51:03 -04:00
option: '--tail'
description: 'continuously stream output'
2014-11-24 12:12:12 -04:00
# TODO: I have to use 'application' instead of 'app' here
# as Commander gets confused with the app command
2014-12-05 11:51:52 -04:00
cli.addOption
option: '-a, --application <app>'
description: 'application id'
coerce: _.parseInt
2014-11-24 12:12:12 -04:00
2014-12-05 11:51:52 -04:00
cli.addOption
2014-12-01 11:40:58 -04:00
option: '-w, --network <network>'
description: 'network type when downloading OS'
2014-12-05 11:51:52 -04:00
cli.addOption
2014-12-01 11:40:58 -04:00
option: '-s, --wifi-ssid <wifiSsid>'
description: 'wifi ssid, if network is wifi'
2014-12-05 11:51:52 -04:00
cli.addOption
2014-12-01 11:40:58 -04:00
option: '-k, --wifi-key <wifiKey>'
description: 'wifi key, if network is wifi'
2014-12-05 11:51:52 -04:00
cli.addOption
2014-12-02 11:53:34 -04:00
option: '-o, --output <output>'
description: 'output file'
2014-11-18 11:37:29 -04:00
# ---------- Auth Module ----------
2014-12-05 11:51:52 -04:00
cli.addCommand
command: 'login [username:password]'
description: 'login to resin.io'
action: actions.auth.login
2014-12-05 11:51:52 -04:00
cli.addCommand
command: 'logout'
description: 'logout from resin.io'
action: actions.auth.logout
2014-11-27 10:06:11 -04:00
permission: 'user'
2014-12-05 11:51:52 -04:00
cli.addCommand
command: 'signup'
description: 'signup to resin.io'
action: actions.auth.signup
2014-11-18 11:37:29 -04:00
# ---------- App Module ----------
2014-12-05 11:51:52 -04:00
cli.addResource
name: 'app'
displayName: 'application'
actions: actions.app
2014-11-27 10:06:11 -04:00
permission: 'user'
2014-12-05 11:51:52 -04:00
cli.addCommand
command: 'app:restart <id>'
description: 'restart an application'
action: actions.app.restart
2014-11-27 10:06:11 -04:00
permission: 'user'
2014-11-21 09:43:03 -04:00
2014-11-19 13:38:15 -04:00
# ---------- Device Module ----------
2014-12-05 11:51:52 -04:00
cli.addResource
name: 'device'
displayName: 'device'
actions: actions.device
2014-11-27 10:06:11 -04:00
permission: 'user'
2014-12-05 11:51:52 -04:00
cli.addCommand
command: 'device:identify <uuid>'
description: 'identify a device with a UUID'
action: actions.device.identify
2014-11-27 10:06:11 -04:00
permission: 'user'
2014-11-21 14:21:47 -04:00
2014-11-19 08:59:17 -04:00
# ---------- Preferences Module ----------
2014-12-05 11:51:52 -04:00
cli.addCommand
command: 'preferences'
description: 'open preferences form'
action: actions.preferences.preferences
permission: 'user'
2014-11-20 12:13:59 -04:00
2014-11-20 13:02:29 -04:00
# ---------- Keys Module ----------
2014-12-05 11:51:52 -04:00
cli.addResource
name: 'key'
displayName: 'ssh key'
actions: actions.keys
2014-11-27 10:06:11 -04:00
permission: 'user'
2014-11-21 13:56:11 -04:00
2014-11-24 12:12:12 -04:00
# ---------- Env Module ----------
2014-12-05 11:51:52 -04:00
cli.addResource
name: 'env'
displayName: 'environment variable'
actions: actions.env
2014-11-27 10:06:11 -04:00
permission: 'user'
2014-11-24 13:00:36 -04:00
2014-11-28 12:46:24 -04:00
# ---------- Logs Module ----------
2014-12-05 11:51:52 -04:00
cli.addCommand
2014-11-28 12:46:24 -04:00
command: 'logs <uuid>'
description: 'show device logs'
action: actions.logs.logs
permission: 'user'
2014-12-02 11:08:22 -04:00
# ---------- OS Module ----------
2014-12-05 11:51:52 -04:00
cli.addCommand
2014-12-02 11:08:22 -04:00
command: 'os:download <id>'
description: 'download device OS'
action: actions.os.download
permission: 'user'
2014-12-05 10:53:59 -04:00
resin.data.prefix.set resin.settings.get('dataPrefix'), (error) ->
2014-11-26 14:17:26 -04:00
resin.errors.handle(error) if error?
2014-12-05 11:51:52 -04:00
cli.parse(process.argv)
2014-12-05 11:51:52 -04:00
quiet = cli.getArgument('quiet')
resin.log.setQuiet(quiet)