nodejs-bash-completion/pm-install

43 lines
1.3 KiB
JavaScript
Executable File

#!/usr/bin/env node
const This = require('./this');
const util = require('util');
class PmInstall extends This {
constructor() {
super();
this.version = '0.0.1';
this.description = 'Install package with fake package manager'
super.init(); // initialize commander with overridden version and description
}
start() {
// Usage
const pmInstall = new PmInstall();
// Output: Methods of ExampleClass: [ 'methodOne', 'methodTwo' ]
// Properties of ExampleClass: [ 'propertyOne', 'propertyTwo', 'version' ] and Version: 1.1.0
// pmInstall.discovery();
this.program
.usage('-n 3 32 -l x y z -- op')
.option('-n, --number <numbers...>', 'specify numbers')
.option('-l, --letter [letters...]', 'specify letters')
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.execCmd(`./log echo 'Options: ${opts}'`);
this.execCmd(`./log echo 'Remaining arguments: ${args}'`);
} else {
this.program.outputHelp();
}
}
}
// main
const pmInstall = new PmInstall();
pmInstall.start();