Add optional interactivity to login command

This commit is contained in:
Juan Cruz Viotti 2014-11-18 12:15:40 -04:00
parent 275eed82f0
commit 24f50fa5ec
2 changed files with 15 additions and 3 deletions

View File

@ -1,10 +1,22 @@
open = require('open')
async = require('async')
auth = require('../auth/auth')
widgets = require('../widgets/widgets')
config = require('../config')
exports.login = (credentials) ->
parsedCredentials = auth.parseCredentials(credentials)
auth.login parsedCredentials, (error) ->
async.waterfall [
(callback) ->
if credentials?
return auth.parseCredentials(credentials, callback)
else
return widgets.login(callback)
(credentials, callback) ->
auth.login(credentials, callback)
], (error) ->
throw error if error?
exports.logout = ->

View File

@ -10,7 +10,7 @@ program.version(packageJSON.version)
auth = require('./actions/auth')
program
.command('login <username:password>')
.command('login [username:password]')
.description('Login with your resin.io account')
.action(auth.login)