const repl = require("repl");

class REPL {
  constructor(options) {
    this.env = options.env;
    this.plugins = options.plugins;
  }

  start(done) {
    this.replServer = repl.start({
      prompt: "Embark (" + this.env + ") > ",
      useGlobal: true
    });

    this.replServer.on("exit", () => {
      process.exit();
    });

    let self = this;
    this.replServer.defineCommand('profile', {
      help: 'Profile a contract',
      action(contract) {
        this.clearBufferedCommand();
        let pluginCmds = self.plugins.getPluginsProperty('console', 'console');
        for (let pluginCmd of pluginCmds) {
          pluginCmd.call(self, `profile ${contract}`, {});
        }
        this.displayPrompt();
      }
    });

    done();
  }

}

module.exports = REPL;

@@ -24,16 +24,58 @@
 epl%22);%0A%0A
+const Console = require('./console.js');%0A%0A
 class RE
@@ -174,199 +174,159 @@
 ;%0A  
-%7D%0A%0A  start(done) %7B%0A    this.replServer = repl.start(%7B%0A      prompt: %22Embark (%22 + this.env + %22) %3E %22,%0A      useGlobal: true%0A    %7D);%0A%0A    this.replServer.on(%22exit%22, () =%3E %7B%0A      process.exit();
+  this.events = options.events;%0A    this.console = new Console(%7B%0A      events: this.events,%0A      plugins: this.plugins,%0A      version: options.version
 %0A   
@@ -334,403 +334,391 @@
 %7D);%0A
-%0A
   
-  let self = this;%0A    this.replServer.defineCommand('profile', %7B%0A      help: 'Profile a contract',%0A      action(contract) %7B%0A        this.clearBufferedCommand();%0A        let pluginCmds = self.plugins.getPluginsProperty('console', 'console');%0A        for (let pluginCmd of pluginCmds) %7B%0A          pluginCmd.call(self, %60profile $%7Bcontract%7D%60, %7B%7D);%0A        %7D%0A        this.displayPrompt();%0A      %7D
+%7D%0A%0A  enhancedEval(cmd, context, filename, callback) %7B%0A    this.console.executeCmd(cmd.trim(), (result) =%3E %7B%0A      callback(null, result);%0A    %7D);%0A  %7D%0A%0A  start(done) %7B%0A    this.replServer = repl.start(%7B%0A      prompt: %22Embark (%22 + this.env + %22) %3E %22,%0A      useGlobal: true,%0A      eval: this.enhancedEval.bind(this)%0A    %7D);%0A%0A    this.replServer.on(%22exit%22, () =%3E %7B%0A      process.exit();
 %0A   

Use console and override evaluator