Package Exports
- coa
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (coa) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Command-Option-Argument
COA is a yet another parser for command line options. You can choose one of the existing modules, or write your own like me.
Examples
require('coa').Cmd() // main command declaration
.name(process.argv[1])
.title('My awesome command line util')
.helpful()
.opt()
.name('version').short('v').long('version')
.title('Version')
.type(Boolean)
.end()
.act(function(opts) {
opts.version &&
this.exit(
JSON.parse(require('fs').readFileSync(__dirname + '/package.json'))
.version);
})
.cmd().name('subcommand).apply(require('./subcommand').COA).end() // load subcommand from module
.cmd() // inplace subcommand declaration
.name('othercommand')
.title('Awesome other subcommand').helpful()
.opt()
.name('input').short('i').long('input')
.title('input file, required')
.validate(function(f) { return require('fs').createReadStream(f) })
.required()
.end()
.end()
.parse(process.argv.slice(2));
// subcommand.js
exports.COA = function() {
this
.title('Awesome subcommand').helpful()
.opt()
.name('output').short('o').long('output')
.title('output file')
.output() // use default preset for "output" option declaration
.end()
};