mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-11 14:24:24 +00:00
refactor console cmd exec
This commit is contained in:
parent
eb6236da65
commit
531af6234b
@ -34,6 +34,10 @@ class Dashboard {
|
||||
self.events.on('contractsState', monitor.setContracts);
|
||||
self.events.on('status', monitor.setStatus.bind(monitor));
|
||||
|
||||
self.events.setCommandHandler("console:command", (cmd, cb) => {
|
||||
cb(monitor.executeCmd(cmd));
|
||||
});
|
||||
|
||||
self.logger.info('========================'.bold.green);
|
||||
self.logger.info(('Welcome to Embark ' + self.version).yellow.bold);
|
||||
self.logger.info('========================'.bold.green);
|
||||
|
@ -344,30 +344,22 @@ class Dashboard {
|
||||
self.input.focus();
|
||||
});
|
||||
|
||||
this.input.on('submit', function (data) {
|
||||
if (data !== '') {
|
||||
self.history.addCommand(data);
|
||||
self.logText.log('console> '.bold.green + data);
|
||||
self.console.executeCmd(data, function (result) {
|
||||
this.input.on('submit', this.executeCmd.bind(this));
|
||||
|
||||
this.screen.append(this.consoleBox);
|
||||
}
|
||||
|
||||
executeCmd(cmd) {
|
||||
const self = this;
|
||||
if (cmd !== '') {
|
||||
self.history.addCommand(cmd);
|
||||
self.logText.log('console> '.bold.green + cmd);
|
||||
self.console.executeCmd(cmd, function (result) {
|
||||
self.logText.log(result);
|
||||
});
|
||||
}
|
||||
self.input.clearValue();
|
||||
self.input.focus();
|
||||
});
|
||||
|
||||
// TODO: can put cmd exe code into its own method, then set this handler
|
||||
// outside this
|
||||
this.events.setCommandHandler("console:command", (cmd, cb) => {
|
||||
self.history.addCommand(cmd);
|
||||
self.logText.log('console> '.bold.green + cmd);
|
||||
self.console.executeCmd(cmd, function (result) {
|
||||
self.logText.log(result);
|
||||
cb(result);
|
||||
});
|
||||
});
|
||||
|
||||
this.screen.append(this.consoleBox);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user