mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-31 08:25:36 +00:00
Attempt to open a browser to the token location automatically
This commit is contained in:
parent
77695bb505
commit
1cd0f02db5
@ -1,5 +1,7 @@
|
||||
(function() {
|
||||
var _, async, resin, url, visuals;
|
||||
var TOKEN_URL, _, async, open, resin, url, visuals;
|
||||
|
||||
open = require('open');
|
||||
|
||||
_ = require('lodash-contrib');
|
||||
|
||||
@ -27,13 +29,23 @@
|
||||
}
|
||||
};
|
||||
|
||||
TOKEN_URL = 'https://dashboard.resin.io/preferences?tab=details';
|
||||
|
||||
exports.login = {
|
||||
signature: 'login [token]',
|
||||
description: 'login to resin.io',
|
||||
help: 'Use this command to login to your resin.io account.\n\nTo login, you need your token, which is accesible from the preferences page:\n\n https://dashboard.resin.io/preferences?tab=details\n\nExamples:\n\n $ resin login\n $ resin login "eyJ0eXAiOiJKV1Qi..."',
|
||||
help: "Use this command to login to your resin.io account.\n\nTo login, you need your token, which is accesible from the preferences page:\n\n " + TOKEN_URL + "\n\nExamples:\n\n $ resin login\n $ resin login \"eyJ0eXAiOiJKV1Qi...\"",
|
||||
action: function(params, options, done) {
|
||||
console.info("To login to the Resin CLI, you need your unique token, which is accesible from\nthe preferences page at " + TOKEN_URL + "\n\nAttempting to open a browser at such location...");
|
||||
return async.waterfall([
|
||||
function(callback) {
|
||||
return open(TOKEN_URL, function(error) {
|
||||
if (error != null) {
|
||||
console.error("Unable to open a web browser in the current environment.\nPlease visit " + TOKEN_URL + " manually.");
|
||||
}
|
||||
return callback();
|
||||
});
|
||||
}, function(callback) {
|
||||
if (params.token != null) {
|
||||
return callback(null, params.token);
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
open = require('open')
|
||||
_ = require('lodash-contrib')
|
||||
url = require('url')
|
||||
async = require('async')
|
||||
@ -21,24 +22,43 @@ exports.whoami =
|
||||
console.log(username)
|
||||
return done()
|
||||
|
||||
TOKEN_URL = 'https://dashboard.resin.io/preferences?tab=details'
|
||||
|
||||
exports.login =
|
||||
signature: 'login [token]'
|
||||
description: 'login to resin.io'
|
||||
help: '''
|
||||
help: """
|
||||
Use this command to login to your resin.io account.
|
||||
|
||||
To login, you need your token, which is accesible from the preferences page:
|
||||
|
||||
https://dashboard.resin.io/preferences?tab=details
|
||||
#{TOKEN_URL}
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin login
|
||||
$ resin login "eyJ0eXAiOiJKV1Qi..."
|
||||
'''
|
||||
"""
|
||||
action: (params, options, done) ->
|
||||
|
||||
console.info """
|
||||
To login to the Resin CLI, you need your unique token, which is accesible from
|
||||
the preferences page at #{TOKEN_URL}
|
||||
|
||||
Attempting to open a browser at such location...
|
||||
"""
|
||||
|
||||
async.waterfall([
|
||||
|
||||
(callback) ->
|
||||
open TOKEN_URL, (error) ->
|
||||
if error?
|
||||
console.error """
|
||||
Unable to open a web browser in the current environment.
|
||||
Please visit #{TOKEN_URL} manually.
|
||||
"""
|
||||
return callback()
|
||||
|
||||
(callback) ->
|
||||
return callback(null, params.token) if params.token?
|
||||
visuals.widgets.ask('What\'s your token? (visible in the preferences page)', null, callback)
|
||||
|
Loading…
x
Reference in New Issue
Block a user