Changelog
1.2.2
{{name}}
-replacement in subcmd help templates: all {{name}} usages
are replaced. Change from using the subcommand name as the value of
{{name}}
to the tool name (i.e. the top-level command name).Changelog
1.2.1
Pass the subcmd
back as the second arg in the <cli>.main
callback. This
enabled the subcmd to be quoted in an error message if there was an err
returned. E.g.:
var cli = new Mo();
cli.main(process.argv, function (err, subcmd) {
if (err) {
var subcmdStr = subcmd ? ' ' + subcmd : ''; // <---- HERE
if (err.body && err.body.code) {
console.error('%s%s: error (%s): %s', cli.name, subcmdStr,
err.body.code, err.message);
} else {
console.error('%s%s: error: %s', cli.name, subcmdStr,
err.message);
}
if (cli.opts.verbose && err.stack) {
console.error('\n' + err.stack);
}
process.exit(1);
} else {
process.exit(0);
}
});
Changelog
1.2.0
[Backward incompatible change] Underscores in sub-command do_*
methods
are translated to hyphens for the sub-command name. This means you can
have sub-commands with hyphens, at the cost of not allowing underscores.
A sub-command method like this:
MyCmdln.prototype.do_foo_bar
results in a 'foo-bar' sub-command.
Shout if this breaks you. I could see about making this configurable.
Changelog
1.1.4
type: 'bool'
, default
and
env
(IOW, rare).Changelog
1.1.0
Add cmdln.main
for simpler mainline usage, e.g.:
function MyTool() {
// ...
}
util.inherits(MyTool, cmdln.Cmdln);
// ...
if (require.main === module) {
cmdln.main(MyTool);
}
Drop support for 'help_FOO' help commands. Not worth the complexity.
Allow custom options given in constructor and a Cmdln.prototype.init
hook that is called to handle the top-level options after they are
parsed out and before subcmd dispatch. See "examples/conan.js" for
an example.
Top-level options are put on this.opts
for use by subcmds.