Comparing version 0.4.0 to 0.4.1
@@ -115,11 +115,11 @@ // Generated by CoffeeScript 1.6.3 | ||
if (!opt._flag && opt._comp) { | ||
compls = Q.join(compls, Q.when(opt._comp(opts), function(c, o) { | ||
compls = Q.all([compls, opt._comp(opts)]).spread(function(c, o) { | ||
return c.concat(o.map(function(v) { | ||
return (optPrefix || '') + v; | ||
})); | ||
})); | ||
}); | ||
} | ||
} | ||
if (cmd._comp) { | ||
compls = Q.join(compls, Q.when(cmd._comp(opts)), function(c, o) { | ||
compls = Q.all([compls, cmd._comp(opts)]).spread(function(c, o) { | ||
return c.concat(o); | ||
@@ -126,0 +126,0 @@ }); |
{ | ||
"name": "coa", | ||
"description": "Command-Option-Argument: Yet another parser for command line options.", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"homepage": "http://github.com/veged/coa", | ||
@@ -6,0 +6,0 @@ "author": "Sergey Berezhnoy <veged@ya.ru> (http://github.com/veged)", |
@@ -12,2 +12,3 @@ # Command-Option-Argument | ||
* Shell completion | ||
* Subcommand extendibility by external node modules | ||
@@ -23,2 +24,4 @@ ### Other features | ||
* --Subcommand extendibility-- | ||
* Shell completion helpers | ||
* Localization | ||
@@ -49,10 +52,18 @@ * Shell-mode | ||
.end() // end option chain and return to main command | ||
.cmd().name('subcommand').apply(require('./subcommand').COA).end() // load subcommand from module | ||
.cmd() | ||
.name('subcommand') | ||
.apply(require('./subcommand')) // load subcommand from module | ||
.end() | ||
.cmd() // inplace subcommand declaration | ||
.name('othercommand').title('Awesome other subcommand').helpful() | ||
.name('othercommand') | ||
.title('Awesome other subcommand') | ||
.helpful() | ||
.opt() | ||
.name('input').title('input file, required') | ||
.short('i').long('input') | ||
.name('input') | ||
.title('input file, required') | ||
.short('i') | ||
.long('input') | ||
.val(function(v) { // validator function, also for translate simple values | ||
return require('fs').createReadStream(v) }) | ||
return require('fs').createReadStream(v); | ||
}) | ||
.req() // make option required | ||
@@ -66,8 +77,10 @@ .end() // end option chain and return to command | ||
// subcommand.js | ||
exports.COA = function() { | ||
module.exports = function() { | ||
this | ||
.title('Awesome subcommand').helpful() | ||
.opt() | ||
.name('output').title('output file') | ||
.short('o').long('output') | ||
.name('output') | ||
.title('output file') | ||
.short('o') | ||
.long('output') | ||
.output() // use default preset for "output" option declaration | ||
@@ -147,2 +160,12 @@ .end() | ||
#### Cmd.extendable | ||
Adds ability to extend command by external node modules.<br> | ||
**@param** *String* `[pattern]` Pattern of modules names to search. | ||
Should be simple string with `%s` placeholder like `coa-program-%s-subcommand` | ||
or without it — it will be treated as module name prefix then. E.g. `coa-program-`.<br> | ||
Node module should export function or `Cmd` object. Function will be passed | ||
to `Cmd.apply()` method of created subcommand object using `Cmd.cmd()` method. And | ||
`Cmd` object will be passed to `Cmd.cmd()` method. | ||
**@returns** *COA.Cmd* `this` instance (for chainability) | ||
#### Cmd.usage | ||
@@ -149,0 +172,0 @@ Build full usage text for current command instance.<br> |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94207
346