From 74f0d05ca03956168b12a39ffb8a90447715f70d Mon Sep 17 00:00:00 2001 From: Subramanian Venkatesan Date: Sun, 9 Sep 2018 23:07:55 +0530 Subject: [PATCH] Plugin Command --- cmd/cmd_controller.js | 2 +- lib/core/engine.js | 7 ++++++- lib/modules/plugin_cmd/index.js | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 lib/modules/plugin_cmd/index.js diff --git a/cmd/cmd_controller.js b/cmd/cmd_controller.js index 6e35d3b2..cdb9bfaa 100644 --- a/cmd/cmd_controller.js +++ b/cmd/cmd_controller.js @@ -280,7 +280,7 @@ class EmbarkController { engine.startService("webServer"); engine.startService("namingSystem"); engine.startService("console"); - + engine.startService("pluginCommand"); return callback(); } diff --git a/lib/core/engine.js b/lib/core/engine.js index 7554d43f..013df106 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -70,7 +70,8 @@ class Engine { "processManager": this.processManagerService, "storage": this.storageService, "graph": this.graphService, - "codeCoverage": this.codeCoverageService + "codeCoverage": this.codeCoverageService, + "pluginCommand": this.pluginCommandService }; let service = services[serviceName]; @@ -130,6 +131,10 @@ class Engine { this.servicesMonitor.startMonitor(); } + pluginCommandService() { + this.registerModule('plugin_cmd'); + } + namingSystem(_options) { this.registerModule('ens'); } diff --git a/lib/modules/plugin_cmd/index.js b/lib/modules/plugin_cmd/index.js new file mode 100644 index 00000000..111f5d75 --- /dev/null +++ b/lib/modules/plugin_cmd/index.js @@ -0,0 +1,18 @@ +class PluginCommand { + constructor(embark) { + console.log(embark); + //this.embark = embark; + //this.registerCommands(); + } + registerCommands() { + const self = this; + self.embark.registerConsoleCommand((cmd, _options) => { + return { + match: () => cmd === 'webserver start', + process: (cb) => self.events.request('start-webserver', cb) + }; + }); + } +} + +module.exports = PluginCommand;