Socket
Socket
Sign inDemoInstall

cmdln

Package Overview
Dependencies
5
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install
2345Next

7.0.0

Diff

Changelog

Source

7.0.0

  • [Backward incompatible change] This changes the formatting of "error info" -- a feature introduced in v6.0.0. There are two changes:

    1. Error info is now always rendered via JSON.stringify. Previously that was only done if showErrStack. This deals with an issue where the other rendering would result in, e.g., res: [object Object] if the info value was an Object.
    2. Indentation has been increased.

    Before v7.0.0 example:

    $ mytool list
    mytool list: error: 3 errors:
        error gathering rebalancer-agent info on storage inst 70521b69-4c31-469b-b120-00d7e2300517
        error gathering rebalancer-agent info on storage inst 887bb8e7-5117-4173-a9a3-6499ab10651c
        error gathering rebalancer-agent info on storage inst 20e480c9-fb66-4a64-8d92-c2f89e496da1
        res: [object Object]
    

    With v7.0.0 example:

    $ mytool list
    mytool list: error: 3 errors:
        error gathering rebalancer-agent info on storage inst 20e480c9-fb66-4a64-8d92-c2f89e496da1
        error gathering rebalancer-agent info on storage inst 887bb8e7-5117-4173-a9a3-6499ab10651c
        error gathering rebalancer-agent info on storage inst 70521b69-4c31-469b-b120-00d7e2300517
        error info:
            {
                "res": {
                    "uuid": "cc9ad6da-e05e-11e2-8e23-002590c3f078",
                    "hostname": "S12612523509075",
                    "zonename": "20e480c9-fb66-4a64-8d92-c2f89e496da1",
                    "service": "storage",
                    "result": {
                        "exit_status": 2,
                        "stdout": "edfeb9c7-1c22-41ca-ab17-b8c3bfdf8037\nnot-frobbed\n",
                        "stderr": "bash: line 33: syntax error: unexpected end of file\n"
                    }
                }
            }
    
trentm
published 6.0.0 •

Changelog

Source

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.

trentm
published 5.1.0 •

Changelog

Source

5.1.0

  • [issue #19] Add strings config option to Cmdln creation that allows overriding the strings used in some generated output -- in particular the help output headers. E.g., one can use:

    function CLI() {
        Cmdln.call(this, {
            // ...
            strings: {
                helpHeaderUsage: 'USAGE',
                helpHeaderOptions: 'OPTIONS',
                helpHeaderCommands: 'COMMANDS'
            }
    

    To have the CLI help output use "USAGE" rather than "Usage:", etc.

    See https://github.com/trentm/node-cmdln/blob/master/test/cmd/help-header-style.js for a complete example.

trentm
published 5.0.0 •

Changelog

Source

5.0.0

  • [Backward incompatible change, issue #12] Cmdln's dispatch to do_* subcommand handler functions is no longer wrapped in a try/catch block, which means that exceptions from programmer errors will no longer be swallowed. Before this change a programmer error could not be distinguished from a command calling back with a runtime error.

    Take this example:

    var util = require('util');
    var cmdln = require('.');
    
    function CLI() {
        cmdln.Cmdln.call(this, {name: 'boom'});
    }
    util.inherits(CLI, cmdln.Cmdln);
    
    CLI.prototype.do_hi = function (subcmd, opts, args, cb) {
        someMissingHelperFunction(); // OOPS
        cb();
    };
    
    if (require.main === module) {
        cmdln.main(new CLI());
    }
    

    Before cmdln v5:

    $ node boom.js hi
    boom: error: someMissingHelperFunction is not defined
    $ echo $?
    1
    

    And as of this change:

    $ node boom.js hi
    /Users/trentm/tm/node-cmdln/boom.js:10
        someMissingHelperFunction();
        ^
    
    ReferenceError: someMissingHelperFunction is not defined
        at CLI.do_hi (/Users/trentm/tm/node-cmdln/boom.js:10:5)
        at CLI.dispatch (/Users/trentm/tm/node-cmdln/lib/cmdln.js:1315:17)
        at mainInit (/Users/trentm/tm/node-cmdln/lib/cmdln.js:727:14)
        at CLI.init (/Users/trentm/tm/node-cmdln/lib/cmdln.js:965:5)
        at CLI.cmdlnMain [as main] (/Users/trentm/tm/node-cmdln/lib/cmdln.js:702:10)
        at Object.main (/Users/trentm/tm/node-cmdln/lib/cmdln.js:1493:9)
        at Object.<anonymous> (/Users/trentm/tm/node-cmdln/boom.js:15:11)
        at Module._compile (internal/modules/cjs/loader.js:778:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
        at Module.load (internal/modules/cjs/loader.js:653:32)
    $ echo $?
    1
    
  • Switch testing to node-tap (requires node v6 to run test suite).

  • Drop "support" for node 0.8.

  • Switch checking/formatting to eslint/prettier.

trentm
published 4.4.0 •

Changelog

Source

4.4.0

  • [#18] Improve printing of error details in cmdln.main(). Specifically:

    • If the err is a verror.MultiError, then print all of collected errors' messages.
    • With showErrStack use VError.fullStack() to print the full cause chain.
    • With showErrStack print VError.info() if there is any.

    See [issue #18] for examples.

trentm
published 4.3.1 •

Changelog

Source

4.3.1

  • Fix CLI.prototype.defaultHandler to pass through args. Before this change opts and args were undefined. After the change they are opts = {} and args is the array of arguments after the subcmd.`
trentm
published 4.3.0 •

Changelog

Source

4.3.0

  • Add a new CLI.prototype.defaultHandler = function (subcmd, opts, args, cb) hook that can be used for custom handling of giving an unknown sub-command name.
trentm
published 4.2.1 •

Changelog

Source

4.2.1

  • It turns out specifying a finale option to cmdln.main(CLI, OPTIONS) never worked. Fix that.
trentm
published 4.2.0 •

Changelog

Source

4.2.0

  • Expose the includeHidden option to Cmdln#bashCompletion(). It is passed through to Cmdln#bashCompletionSpec(). Also correct a bug where includeHidden did not propagate to nested subcommands.
trentm
published 4.1.2 •

Changelog

Source

4.1.2

  • [trentm/node-dashdash#30] Change the output used by Bash completion support to indicate "there are no completions for this argument" to cope with different sorting rules on different Bash/platforms.
2345Next
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc