mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-10 22:05:55 +00:00
refactor: extract method for cmd interpreter
This commit is contained in:
parent
11eca918a1
commit
4c5cb95209
@ -10,15 +10,7 @@ Console.prototype.runCode = function(code) {
|
||||
RunCode.doEval(code); // jshint ignore:line
|
||||
};
|
||||
|
||||
Console.prototype.executeCmd = function(cmd, callback) {
|
||||
var plugin, pluginOutput;
|
||||
var plugins = this.plugins.getPluginsFor('console');
|
||||
for (var i = 0; i < plugins.length; i++) {
|
||||
plugin = plugins[i];
|
||||
pluginOutput = plugin.runCommands(cmd, {});
|
||||
if (pluginOutput !== false && pluginOutput !== 'false') return callback(pluginOutput);
|
||||
}
|
||||
|
||||
Console.prototype.processEmbarkCmd = function(cmd) {
|
||||
if (cmd === 'help') {
|
||||
var helpText = [
|
||||
'Welcome to Embark ' + this.version,
|
||||
@ -31,10 +23,26 @@ Console.prototype.executeCmd = function(cmd, callback) {
|
||||
'',
|
||||
'The web3 object and the interfaces for the deployed contracts and their methods are also available'
|
||||
];
|
||||
return callback(helpText.join('\n'));
|
||||
return helpText.join('\n');
|
||||
} else if (cmd === 'quit') {
|
||||
utils.exit();
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
Console.prototype.executeCmd = function(cmd, callback) {
|
||||
var plugin, pluginOutput;
|
||||
var plugins = this.plugins.getPluginsFor('console');
|
||||
for (var i = 0; i < plugins.length; i++) {
|
||||
plugin = plugins[i];
|
||||
pluginOutput = plugin.runCommands(cmd, {});
|
||||
if (pluginOutput !== false && pluginOutput !== 'false') return callback(pluginOutput);
|
||||
}
|
||||
|
||||
var output = this.processEmbarkCmd(cmd);
|
||||
if (output) {
|
||||
return callback(output);
|
||||
}
|
||||
|
||||
try {
|
||||
var result = RunCode.doEval(cmd);
|
||||
|
Loading…
x
Reference in New Issue
Block a user