#!/usr/bin/env node const This = require('./this'); const util = require('util'); class Log extends This { constructor() { super(); this.version = '0.0.1'; this.description = 'Helper script for building log messages'; super.init(); // initialize commander with overridden version and description } echo(str) { console.log(str); } success(str) { console.log(this._echoInGreen(str)); } info(str) { console.log(`[INFO] ${str}`); } warn(str) { console.warn(`[WARN] ${this._echoInYellow(str)}`); } error(str) { console.error(`[ERR] ${this._echoInRed(str)}`); } start() { this.program.command('echo') .argument('') .action(message => { this.echo(message); }); this.program.command('success') .argument('') .action(message => { this.success(message); }); this.program.command('info') .argument('') .action(message => { this.info(message); }); this.program.command('warn') .argument('') .action(message => { this.warn(message); }); this.program.command('error') .argument('') .action(message => { this.error(message); }); this.program.parse(); if (Object.keys(this.program.opts()).length || this.program.args.length) { //// Debugging commander options and arguments const opts = util.inspect(this.program.opts(), { depth: null, colors: true, showHidden: true }); const args = util.inspect(this.program.args, { depth: null, colors: true, showHidden: true }); //this.echo(`Options: ${opts}`); //this.echo(`Remaining arguments: ${args}`); } else { this.program.outputHelp(); } } } // main const log = new Log(); log.start();