veged/coa — pull request #38 by arikon (2013-07-09 09:07:56+00:00)
Title: Basic support for external commands as packages

We could write subcommands as npm packages and name them as `program-subcommand`.

`program-subcommand` should export `COA.Cmd()` instance object or function that should call methods on `this`.

### Examples

#### Export function

```js
module.exports = function() {

return this
.name('test')
.opt()
.name('opt')
.long('opt')
.end()
.arg()
.name('arg1')
.end()
.arg()
.name('arg2')
.arr()
.end()
.act(function(opts, args) {
return { opts: opts, args: args };
});

};
```

#### Export command instance

```js
var COA = require('..');

module.exports = COA.Cmd()
.name('test-obj')
.opt()
.name('opt')
.long('opt')
.end()
.arg()
.name('arg1')
.end()
.arg()
.name('arg2')
.arr()
.end()
.act(function(opts, args) {
return { opts: opts, args: args };
})
.end();
```