Socket
Socket
Sign inDemoInstall

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 5.1.0 to 6.0.0

42

CHANGES.md

@@ -7,2 +7,44 @@ # node-cmdln Changelog

## 6.0.0
- [Backward incompatible change] Drop support for `cmdln.main()` accepting a
non-Error instance from a `<Cmdln>.main()`. Before this change a subcommand
calling back with something like `callback(true)` would "work". Now it
will throw:
AssertionError [ERR_ASSERTION]: err from main is not an Error: true
- [Backward incompatible change] Drop the undocumented `cli.suppressShowErr`
option.
- [Backward incompatible change] Add `showErrInfo` option to `cmdln.main()`.
"Error info" is additional info on an error instance in the callback from
the run command, per <https://github.com/joyent/node-verror#verrorinfoerr>.
For example, you could have code like this in a subcommand handler:
var err = new VError(
{
name: 'NotEnoughSpaceError'
info: {'x-request-id': response.headers['x-request-id']
},
'not enough free space for 5120 MB'
);
err.code = 'NotEnoughSpace';
cb(err);
Here that `info: ...` object is the "error info". That would look like
the following on the command-line:
mbucket cp: error (NotEnoughSpace): not enough free space for 5120 MB
x-request-id: 5f41a396-e800-4d64-8b01-11e65fe74aa5
This is a backward incompatible change if you already have subcommands that
can return a `VError` instance with info. To get the old behaviour, use:
cmdln.main(cli, {showErrInfo: false});
Note that before this change, error info was *already* being shown in the
output when `showErrStack` was true.
## 5.1.0

@@ -9,0 +51,0 @@

44

lib/cmdln.js

@@ -1460,2 +1460,5 @@ /*

* error help. Default true.
* - `showErrInfo` {Boolean} Optional. Default true. Whether to show
* error info (per <https://github.com/joyent/node-verror#verrorinfoerr>)
* when reporting the error from a subcommand.
*

@@ -1548,15 +1551,10 @@ * Some fields can be set on the Cmdln instance, `<cli>`, to control error

if (err && showErr) {
assert.ok(
util.isError(err),
'err from main is not an Error: ' + err
);
var code = err.body ? err.body.code : err.code;
if (code === 'NoCommand' && !options.showNoCommandErr) {
/* jsl:pass */
} else if (!cli.suppressShowErr && err.message !== undefined) {
// If the `err` has no "message" field, then this probably
// isn't an Error instance. Let's just not print an error
// message. This can happen if the subcmd passes back `true`
// or similar to indicate "yes there was an error".
// *Dev Note*: This "ignore a non-Error err" behaviour should
// be dropped in a future major version bump.
//
// We unroll a verror.MultiError to attempt to show its
// collected error messages.
} else {
var showErrStack =

@@ -1567,2 +1565,4 @@ options.showErrStack === undefined

// Unroll a verror.MultiError to attempt to show its
// collected error messages.
var errDetails;

@@ -1594,8 +1594,24 @@ // `.ase_errors` is an verror impl detail.

if (showErrStack) {
// Optionally show "error info" per `VError.info()`
// https://github.com/joyent/node-verror#verrorinfoerr
var showErrInfo =
options.showErrInfo === undefined
? true
: options.showErrInfo;
if (showErrInfo) {
var errInfo = VError.info(err);
if (Object.keys(errInfo).length !== 0) {
errDetails +=
'\nerror info:\n' +
indentLines(JSON.stringify(errInfo, null, 4));
if (showErrStack) {
errDetails +=
'\n error info:\n' +
indentLines(JSON.stringify(errInfo, null, 4));
} else if (showErrInfo) {
errDetails +=
'\n' +
Object.keys(errInfo)
.map(function onK(k) {
return ' ' + k + ': ' + errInfo[k];
})
.join('\n');
}
}

@@ -1602,0 +1618,0 @@ }

{
"name": "cmdln",
"version": "5.1.0",
"version": "6.0.0",
"description": "helper lib for creating CLI tools with subcommands; think `git`, `svn`, `zfs`",

@@ -5,0 +5,0 @@ "author": "Trent Mick (http://trentm.com)",

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