balena-cli/lib/app.coffee

133 lines
3.0 KiB
CoffeeScript
Raw Normal View History

2014-11-24 16:12:12 +00:00
_ = require('lodash')
2014-11-26 16:38:02 +00:00
resin = require('./resin')
2014-11-18 12:35:50 +00:00
config = require('./config')
2014-11-21 13:23:02 +00:00
packageJSON = require('../package.json')
2014-11-17 19:48:26 +00:00
2014-11-21 13:23:02 +00:00
program = require('commander')
program.version(packageJSON.version)
2014-11-20 16:05:50 +00:00
# ---------- Options ----------
program.option('-y, --yes', 'confirm non interactively')
program.option('-v, --verbose', 'increase verbosity')
2014-11-21 16:20:37 +00:00
program.option('-q, --quiet', 'quiet (no output)')
program.option('-t, --type <type>', 'specify a type when creating an application')
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
program.option('-a, --application <app>', 'application id', _.parseInt)
2014-11-18 15:37:29 +00:00
# ---------- Auth Module ----------
auth = require('./actions/auth')
2014-11-21 13:23:02 +00:00
program
.command('login [username:password]')
.description('Login to resin.io')
.action(auth.login)
program
.command('logout')
.description('Logout from resin.io')
.action(auth.logout)
program
.command('signup')
.description('Signup to resin.io')
.action(auth.signup)
2014-11-18 15:37:29 +00:00
# ---------- App Module ----------
app = require('./actions/app')
2014-11-21 13:23:02 +00:00
program
.command('app:create <name>')
.description('Create a resin.io application')
.action(app.create)
2014-11-21 13:23:02 +00:00
program
.command('apps')
.description('List your applications')
.action(app.list)
program
.command('app <id>')
.description('List a single application')
.action(app.info)
program
.command('app:restart <id>')
.description('Restart an application')
.action(app.restart)
2014-11-19 13:23:40 +00:00
2014-11-21 13:43:03 +00:00
program
.command('app:rm <id>')
.description('Remove an application')
.action(app.remove)
2014-11-19 17:38:15 +00:00
# ---------- Device Module ----------
device = require('./actions/device')
2014-11-21 13:23:02 +00:00
program
.command('devices <id>')
.description('Show devices for an application')
.action(device.list)
2014-11-19 17:38:15 +00:00
2014-11-21 17:23:29 +00:00
program
.command('device:rm <id>')
.description('Remove a device')
.action(device.remove)
2014-11-21 18:21:47 +00:00
program
.command('device:identify <uuid>')
.description('Identify a device with a UUID')
.action(device.identify)
2014-11-19 12:59:17 +00:00
# ---------- Preferences Module ----------
preferences = require('./actions/preferences')
2014-11-21 13:23:02 +00:00
program
.command('preferences')
.description('Open preferences form')
.action(preferences.preferences)
2014-11-19 12:59:17 +00:00
# ---------- Info Module ----------
2014-11-21 13:23:02 +00:00
program
.command('version')
.description('Show version')
.action ->
2014-11-26 16:38:02 +00:00
resin.log.out(packageJSON.version)
2014-11-20 16:13:59 +00:00
2014-11-20 17:02:29 +00:00
# ---------- Keys Module ----------
keys = require('./actions/keys')
2014-11-21 13:23:02 +00:00
program
.command('keys')
.description('List all SSH keys')
.action(keys.list)
program
.command('key <id>')
.description('List a single SSH key')
.action(keys.info)
2014-11-20 17:02:29 +00:00
2014-11-21 17:56:11 +00:00
program
.command('key:rm <id>')
.description('Remove a SSH key')
.action(keys.remove)
2014-11-24 16:12:12 +00:00
# ---------- Env Module ----------
env = require('./actions/environment-variables')
program
.command('envs')
.description('List all environment variables')
.action(env.list)
2014-11-24 17:00:36 +00:00
program
.command('env:rm <id>')
.description('Remove environment variable')
.action(env.remove)
2014-11-26 16:56:52 +00:00
resin.data.prefix.set config.dataPrefix, (error) ->
2014-11-17 19:48:26 +00:00
throw error if error?
2014-11-21 13:23:02 +00:00
program.parse(process.argv)
2014-11-26 16:38:02 +00:00
resin.log.setQuiet(program.quiet)