From 69dbd49444d8b5ed8fdab52bd426ad58a3c22a18 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 17 Nov 2014 15:48:26 -0400 Subject: [PATCH] Implement simple interface module --- lib/interface/interface.coffee | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lib/interface/interface.coffee diff --git a/lib/interface/interface.coffee b/lib/interface/interface.coffee new file mode 100644 index 00000000..5f451ee7 --- /dev/null +++ b/lib/interface/interface.coffee @@ -0,0 +1,34 @@ +program = require('commander') +packageJSON = require('../../package.json') + +auth = require('../cli-modules/auth/auth') +data = require('../data/data') +server = require('../server/server') +config = require('../config') + +program.version(packageJSON.version) + +program + .command('login ') + .description('Login with your resin.io account') + .action (credentials) -> + parsedCredentials = auth.parseCredentials(credentials) + auth.login parsedCredentials, (error) -> + throw error if error? + +program + .command('apps') + .description('Show a list of your apps') + .action -> + + # TODO: The details of requesting the API should be handled + # by the models. Make use of them once they are implemented + server.get '/ewa/application?$orderby=app_name%20asc&$expand=device', (error, response) -> + for app in response.body.d + console.log "#{app.id} - #{app.app_name}" + +# TODO: Check if not running on UNIX environment +# and add a custom path accordingly +data.prefix.set config.dataPrefix, (error) -> + throw error if error? + program.parse(process.argv)