2016-09-23 04:31:09 +00:00
|
|
|
var Web3 = require('web3');
|
|
|
|
|
|
|
|
var Console = function(options) {
|
|
|
|
};
|
|
|
|
|
|
|
|
Console.prototype.runCode = function(code) {
|
2016-09-25 01:23:57 +00:00
|
|
|
eval(code); // jshint ignore:line
|
2016-09-23 04:31:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Console.prototype.executeCmd = function(cmd, callback) {
|
|
|
|
if (cmd === 'help') {
|
|
|
|
var helpText = [
|
|
|
|
'Welcome to Embark 2',
|
|
|
|
'',
|
|
|
|
'possible commands are:',
|
|
|
|
'quit - to immediatly exit',
|
|
|
|
'',
|
|
|
|
'The web3 object and the interfaces for the deployed contrats and their methods are also available'
|
|
|
|
];
|
|
|
|
return callback(helpText.join('\n'));
|
|
|
|
} else if (cmd === 'quit') {
|
|
|
|
exit();
|
2016-09-25 01:23:57 +00:00
|
|
|
}
|
2016-09-23 04:31:09 +00:00
|
|
|
|
|
|
|
try {
|
2016-09-25 01:23:57 +00:00
|
|
|
var result = eval(cmd); // jshint ignore:line
|
2016-09-23 04:31:09 +00:00
|
|
|
return callback(result);
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
return callback(e.message.red);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Console;
|
|
|
|
|