Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cmdln

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cmdln - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

10

CHANGES.md
# 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 @@

20

lib/cmdln.js

@@ -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 @@ }

2

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc