Comparing version 1.3.1 to 1.3.2
# node-cmdln Changelog | ||
## 1.3.2 | ||
- Add `<Cmdln>.handlerFromSubcmd(<subcmd>)` hook. For example this could allow | ||
a user's Cmdln subclass to lookup attributes on the handler functions | ||
during `<Cmdln>.init()`. | ||
- Don't `process.exit(0)` in `cmdln.main` for success to allow open listeners | ||
to continue. | ||
## 1.3.1 | ||
@@ -4,0 +14,0 @@ |
@@ -368,12 +368,25 @@ /* | ||
/** | ||
* Return the handler function for the given sub-command string. This | ||
* returns undefined if there is no handler for that sub-command. | ||
*/ | ||
Cmdln.prototype.handlerFromSubcmd = function handlerFromSubcmd(subcmd) { | ||
var name = this.aliases[subcmd]; | ||
if (!name) { | ||
return; | ||
} | ||
return this.subcmds[name]; | ||
}; | ||
/** | ||
* Dispatch to the appropriate "do_SUBCMD" function. | ||
*/ | ||
Cmdln.prototype.dispatch = function dispatch(subcmd, argv, callback) { | ||
var name = this.aliases[subcmd]; | ||
if (!name) { | ||
var func = this.handlerFromSubcmd(subcmd); | ||
if (!func) { | ||
callback(new UnknownCommandError(subcmd)); | ||
return; | ||
} | ||
var func = this.subcmds[name]; | ||
@@ -492,3 +505,2 @@ var opts = null; | ||
} | ||
process.exit(0); | ||
}); | ||
@@ -495,0 +507,0 @@ } |
{ | ||
"name": "cmdln", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "helper lib for creating CLI tools with subcommands; think `git`, `svn`, `zfs`", | ||
@@ -5,0 +5,0 @@ "author": "Trent Mick (http://trentm.com)", |
@@ -123,4 +123,17 @@ `node-cmdln` is a node.js helper lib for creating CLI tools with subcommands | ||
# Cmdln API | ||
To use this module you create an object that inherits from `cmdln.Cmdln`. There | ||
are a number of relevant methods on `Cmdln` to can be used. | ||
(TODO: finish documenting these. For now the examples and cmdln.js code are | ||
the best resources.) | ||
- `<Cmdln>.handlerFromSubcmd(<subcmd>)` will return the appropriate | ||
`do_<subcmd>` method that handles the given sub-command. This resolves | ||
sub-command aliases. | ||
# License | ||
MIT. See LICENSE.txt |
@@ -0,1 +1,2 @@ | ||
- <Cmdln>.fini parallel to .init to finalize whatever | ||
- doc helpOpts, helpBody, etc. | ||
@@ -2,0 +3,0 @@ - tests and docs for _ -> - translation in sub-command names |
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
115491
842
139