UNPKG

rawnode-cli

Version:

Raw NodeJs MVC (rawnodejs) CLI

86 lines (72 loc) 1.77 kB
#!/usr/bin/env node "use strict"; /** * @author Ericson Weah Dev * email: ericson.weah@ericsonweah.dev * github: https://github.com/ericson-weah-dev * phone: +1.385.204.5167 * Website: https://www.ericsonweah.dev * * @module CLI * @kind class * * @extends Base * @requires Base * * @classdesc CLI class */ class CLI extends require("./") { constructor(...arrayOfObjects) { super({ objectMode: true, encoding: "utf-8", autoDestroy: true }); arrayOfObjects.forEach(option => { if(Object.keys(option).length > 0){ Object.keys(option).forEach((key) => { if(!this[key]) this[key] = option[key];}) } }); // auto bind methods this.autobind(CLI); // auto invoke methods this.autoinvoker(CLI); // add other classes method if methods do not already exist. Argument order matters! // this.methodizer(..classList); //Set the maximum number of listeners to infinity this.setMaxListeners(Infinity); } command(index = 2){ return process.argv[index] } commands(){ switch(this.command(2)){ case "make": console.log('make man page'); break; case "man": console.log('make man page'); break; case "help": console.log("help man page"); break; default: console.log("invalid command ..."); break; } } init(){ this.commands(); } /** * @name autoinvoked * @function * * @param {Object|Function|Class} className the class whose methods to be bound to it * * @description auto sets the list of methods to be auto invoked * * @return does not return anything * */ autoinvoked() { return ["init"]; } } module.exports = new CLI;