Reuse messages

This commit is contained in:
Juan Cruz Viotti 2016-01-12 10:44:11 -04:00
parent 78ab2af8ba
commit c3a5998d5c
6 changed files with 36 additions and 31 deletions

View File

@ -50,7 +50,7 @@ limitations under the License.
],
primary: true,
action: function(params, options, done) {
var Promise, _, auth, events, form, login, patterns, resin;
var Promise, _, auth, events, form, login, messages, patterns, resin;
_ = require('lodash');
Promise = require('bluebird');
resin = require('resin-sdk');
@ -58,6 +58,7 @@ limitations under the License.
auth = require('resin-cli-auth');
form = require('resin-cli-form');
patterns = require('../utils/patterns');
messages = require('../utils/messages');
login = function(options) {
if (options.token != null) {
return Promise["try"](function() {
@ -82,13 +83,13 @@ limitations under the License.
});
};
return resin.settings.get('resinUrl').then(function(resinUrl) {
console.log('______ _ _\n| ___ \\ (_) (_)\n| |_/ /___ ___ _ _ __ _ ___\n| // _ \\/ __| | \'_ \\ | |/ _ \\\n| |\\ \\ __/\\__ \\ | | | |_| | (_) |\n\\_| \\_\\___||___/_|_| |_(_)_|\\___/');
console.log(messages.resinAsciiArt);
console.log("\nLogging in to " + resinUrl);
return login(options);
}).then(resin.auth.whoami).tap(function(username) {
events.send('user.login');
console.info("Successfully logged in as: " + username);
return console.info('\nNow what?\n\nRun the following command to get a device started with Resin.io\n\n $ resin quickstart\n\nFind out about more super powers by running:\n\n $ resin help\n\nIf you need help, or just want to say hi, don\'t hesitate in reaching out at:\n\n GitHub: https://github.com/resin-io/resin-cli/issues/new\n Gitter: https://gitter.im/resin-io/chat');
return console.info("\nNow what?\n\n" + messages.gettingStarted + "\n\nFind out about more super powers by running:\n\n $ resin help\n\n" + messages.reachingOut);
}).nodeify(done);
}
};

View File

@ -3,4 +3,8 @@
exports.reachingOut = 'If you need help, or just want to say hi, don\'t hesitate in reaching out at:\n\n GitHub: https://github.com/resin-io/resin-cli/issues/new\n Gitter: https://gitter.im/resin-io/chat';
exports.getHelp = 'If you need help, don\'t hesitate in contacting us at:\n\n GitHub: https://github.com/resin-io/resin-cli/issues/new\n Gitter: https://gitter.im/resin-io/chat';
exports.resinAsciiArt = '______ _ _\n| ___ \\ (_) (_)\n| |_/ /___ ___ _ _ __ _ ___\n| // _ \\/ __| | \'_ \\ | |/ _ \\\n| |\\ \\ __/\\__ \\ | | | |_| | (_) |\n\\_| \\_\\___||___/_|_| |_(_)_|\\___/';
}).call(this);

View File

@ -16,7 +16,7 @@ limitations under the License.
*/
(function() {
var Promise, _, chalk, form, resin, validation, visuals;
var Promise, _, chalk, form, messages, resin, validation, visuals;
_ = require('lodash');
@ -32,6 +32,8 @@ limitations under the License.
validation = require('./validation');
messages = require('./messages');
exports.authenticate = function(options) {
return form.run([
{
@ -185,7 +187,7 @@ limitations under the License.
exports.printErrorMessage = function(message) {
console.error(chalk.red(message));
return console.error(chalk.red('\nIf you need help, don\'t hesitate in contacting us at:\n\n GitHub: https://github.com/resin-io/resin-cli/issues/new\n Gitter: https://gitter.im/resin-io/chat\n'));
return console.error(chalk.red("\n" + messages.getHelp + "\n"));
};
}).call(this);

View File

@ -78,6 +78,7 @@ exports.login =
auth = require('resin-cli-auth')
form = require('resin-cli-form')
patterns = require('../utils/patterns')
messages = require('../utils/messages')
login = (options) ->
if options.token?
@ -99,15 +100,7 @@ exports.login =
return login(options)
resin.settings.get('resinUrl').then (resinUrl) ->
console.log '''
______ _ _
| ___ \\ (_) (_)
| |_/ /___ ___ _ _ __ _ ___
| // _ \\/ __| | '_ \\ | |/ _ \\
| |\\ \\ __/\\__ \\ | | | |_| | (_) |
\\_| \\_\\___||___/_|_| |_(_)_|\\___/
'''
console.log(messages.resinAsciiArt)
console.log("\nLogging in to #{resinUrl}")
return login(options)
.then(resin.auth.whoami)
@ -115,23 +108,18 @@ exports.login =
events.send('user.login')
console.info("Successfully logged in as: #{username}")
console.info '''
console.info """
Now what?
Run the following command to get a device started with Resin.io
$ resin quickstart
#{messages.gettingStarted}
Find out about more super powers by running:
$ resin help
If you need help, or just want to say hi, don't hesitate in reaching out at:
GitHub: https://github.com/resin-io/resin-cli/issues/new
Gitter: https://gitter.im/resin-io/chat
'''
#{messages.reachingOut}
"""
.nodeify(done)
exports.logout =

View File

@ -10,3 +10,19 @@ exports.reachingOut = '''
GitHub: https://github.com/resin-io/resin-cli/issues/new
Gitter: https://gitter.im/resin-io/chat
'''
exports.getHelp = '''
If you need help, don't hesitate in contacting us at:
GitHub: https://github.com/resin-io/resin-cli/issues/new
Gitter: https://gitter.im/resin-io/chat
'''
exports.resinAsciiArt = '''
______ _ _
| ___ \\ (_) (_)
| |_/ /___ ___ _ _ __ _ ___
| // _ \\/ __| | '_ \\ | |/ _ \\
| |\\ \\ __/\\__ \\ | | | |_| | (_) |
\\_| \\_\\___||___/_|_| |_(_)_|\\___/
'''

View File

@ -21,6 +21,7 @@ visuals = require('resin-cli-visuals')
resin = require('resin-sdk')
chalk = require('chalk')
validation = require('./validation')
messages = require('./messages')
exports.authenticate = (options) ->
return form.run [
@ -146,11 +147,4 @@ exports.awaitDevice = (uuid) ->
exports.printErrorMessage = (message) ->
console.error(chalk.red(message))
console.error chalk.red '''
If you need help, don't hesitate in contacting us at:
GitHub: https://github.com/resin-io/resin-cli/issues/new
Gitter: https://gitter.im/resin-io/chat
'''
console.error(chalk.red("\n#{messages.getHelp}\n"))