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