UNPKG

nodemss

Version:

Interactive cli tool to list and run start multiple services simultainously

41 lines 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const fs_1 = require("fs"); const main_1 = require("./main"); class CommandLineHandler { constructor(argv) { this.commandLine = argv; } process() { this.processConfigFile(); switch (this.commandLine[2]) { case 'run': this.main.run(); break; case '--config': console.log(`Loaded config file into the system.`); break; default: this.showError(); break; } } showError() { console.log(`Unknown parameters: ${this.commandLine} `); console.log(`Arguments should be: command [run] --config path_to_config_file`); } processConfigFile() { const configLoc = this.commandLine.indexOf('--config'); if (configLoc < 0) { this.showError(); throw Error; } const fileName = this.commandLine[configLoc + 1]; this.main = new main_1.Main(JSON.parse(fs_1.readFileSync(fileName, { encoding: 'UTF-8' }))); } getMain() { return this.main; } } exports.CommandLineHandler = CommandLineHandler; //# sourceMappingURL=command-line-handler.js.map