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-11-17 19:48:26 +00:00
|
|
|
|
2014-11-26 19:05:00 +00:00
|
|
|
resin.cli.setVersion(packageJSON.version)
|
2014-11-20 16:05:50 +00:00
|
|
|
|
2014-11-21 14:44:48 +00:00
|
|
|
# ---------- Options ----------
|
2014-11-26 19:05:00 +00:00
|
|
|
resin.cli.addOption('-y, --yes', 'confirm non interactively')
|
|
|
|
resin.cli.addOption('-v, --verbose', 'increase verbosity')
|
|
|
|
resin.cli.addOption('-q, --quiet', 'quiet (no output)')
|
|
|
|
resin.cli.addOption('-t, --type <type>', 'specify a type when creating an application')
|
2014-11-21 14:44:48 +00:00
|
|
|
|
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-11-26 19:05:00 +00:00
|
|
|
resin.cli.addOption('-a, --application <app>', 'application id', _.parseInt)
|
2014-11-24 16:12:12 +00:00
|
|
|
|
2014-11-18 15:37:29 +00:00
|
|
|
# ---------- Auth Module ----------
|
2014-11-26 19:11:34 +00:00
|
|
|
resin.cli.addCommand('login [username:password]', 'login to resin.io', actions.auth.login)
|
|
|
|
resin.cli.addCommand('logout', 'logout from resin.io', actions.auth.logout)
|
|
|
|
resin.cli.addCommand('signup', 'signup to resin.io', actions.auth.signup)
|
2014-11-18 15:37:29 +00:00
|
|
|
|
|
|
|
# ---------- App Module ----------
|
2014-11-27 13:10:51 +00:00
|
|
|
resin.cli.addResource('app', 'application', actions.app)
|
2014-11-26 19:11:34 +00:00
|
|
|
resin.cli.addCommand('app:restart <id>', 'restart an application', actions.app.restart)
|
2014-11-21 13:43:03 +00:00
|
|
|
|
2014-11-19 17:38:15 +00:00
|
|
|
# ---------- Device Module ----------
|
2014-11-27 13:10:51 +00:00
|
|
|
resin.cli.addResource('device', 'device', actions.device)
|
2014-11-26 19:11:34 +00:00
|
|
|
resin.cli.addCommand('device:identify <uuid>', 'identify a device with a UUID', actions.device.identify)
|
2014-11-21 18:21:47 +00:00
|
|
|
|
2014-11-19 12:59:17 +00:00
|
|
|
# ---------- Preferences Module ----------
|
2014-11-26 19:11:34 +00:00
|
|
|
resin.cli.addCommand('preferences', 'open preferences form', actions.preferences.preferences)
|
2014-11-20 16:13:59 +00:00
|
|
|
|
2014-11-20 17:02:29 +00:00
|
|
|
# ---------- Keys Module ----------
|
2014-11-27 13:10:51 +00:00
|
|
|
resin.cli.addResource('key', 'ssh key', actions.keys)
|
2014-11-21 17:56:11 +00:00
|
|
|
|
2014-11-24 16:12:12 +00:00
|
|
|
# ---------- Env Module ----------
|
2014-11-27 13:10:51 +00:00
|
|
|
resin.cli.addResource('env', 'environment variable', actions.env)
|
2014-11-24 17:00:36 +00:00
|
|
|
|
2014-11-26 17:42:05 +00:00
|
|
|
resin.data.prefix.set resin.config.dataPrefix, (error) ->
|
2014-11-26 18:17:26 +00:00
|
|
|
resin.errors.handle(error) if error?
|
2014-11-26 19:05:00 +00:00
|
|
|
|
|
|
|
resin.cli.parse(process.argv)
|
|
|
|
|
|
|
|
quiet = resin.cli.getArgument('quiet')
|
|
|
|
resin.log.setQuiet(quiet)
|