Socket
Socket
Sign inDemoInstall

commander

Package Overview
Dependencies
Maintainers
3
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commander - npm Package Compare versions

Comparing version 2.8.1 to 2.9.0

9

History.md
2.9.0 / 2015-10-13
==================
* Add option `isDefault` to set default subcommand #415 @Qix-
* Add callback to allow filtering or post-processing of help text #434 @djulien
* Fix `undefined` text in help information close #414 #416 @zhiyelee
2.8.1 / 2015-04-22

@@ -7,4 +14,2 @@ ==================

2.8.0 / 2015-04-07

@@ -11,0 +16,0 @@ ==================

@@ -1,2 +0,1 @@

/**

@@ -86,6 +85,6 @@ * Module dependencies.

this.options = [];
this._execs = [];
this._execs = {};
this._allowUnknownOption = false;
this._args = [];
this._name = name;
this._name = name || '';
}

@@ -169,2 +168,3 @@

this._execs[cmd._name] = true;
if (opts.isDefault) this.defaultExecutable = cmd._name;
}

@@ -189,3 +189,3 @@

return this.parseExpectedArgs(desc.split(/ +/));
}
};

@@ -452,3 +452,3 @@ /**

// github-style sub-commands with no sub-command
if (this.executables && argv.length < 3) {
if (this.executables && argv.length < 3 && !this.defaultExecutable) {
// this user needs help

@@ -468,2 +468,6 @@ argv.push('--help');

return this.executeSubCommand(argv, args, parsed.unknown);
} else if (this.defaultExecutable) {
// use the default subcommand
args.unshift(name = this.defaultExecutable);
return this.executeSubCommand(argv, args, parsed.unknown);
}

@@ -552,2 +556,3 @@

// Store the reference to the child process
this.runningCommand = proc;

@@ -840,3 +845,3 @@ };

Command.prototype.description = function(str) {
if (0 == arguments.length) return this._description;
if (0 === arguments.length) return this._description;
this._description = str;

@@ -920,6 +925,6 @@ return this;

return [pad('-h, --help', width) + ' ' + 'output usage information']
.concat(this.options.map(function(option) {
return pad(option.flags, width) + ' ' + option.description;
.concat(this.options.map(function(option) {
return pad(option.flags, width) + ' ' + option.description;
}))
.join('\n');
.join('\n');
};

@@ -946,10 +951,6 @@

cmd._name
+ (cmd._alias
? '|' + cmd._alias
: '')
+ (cmd.options.length
? ' [options]'
: '')
+ (cmd._alias ? '|' + cmd._alias : '')
+ (cmd.options.length ? ' [options]' : '')
+ ' ' + args
, cmd.description()
, cmd.description()
];

@@ -963,7 +964,8 @@ });

return [
''
''
, ' Commands:'
, ''
, commands.map(function(cmd) {
return pad(cmd[0], width) + ' ' + cmd[1];
var desc = cmd[1] ? ' ' + cmd[1] : '';
return pad(cmd[0], width) + desc;
}).join('\n').replace(/^/gm, ' ')

@@ -1025,4 +1027,9 @@ , ''

Command.prototype.outputHelp = function() {
process.stdout.write(this.helpInformation());
Command.prototype.outputHelp = function(cb) {
if (!cb) {
cb = function(passthru) {
return passthru;
}
}
process.stdout.write(cb(this.helpInformation()));
this.emit('--help');

@@ -1037,4 +1044,4 @@ };

Command.prototype.help = function() {
this.outputHelp();
Command.prototype.help = function(cb) {
this.outputHelp(cb);
process.exit();

@@ -1041,0 +1048,0 @@ };

{
"name": "commander",
"version": "2.8.1",
"version": "2.9.0",
"description": "the complete solution for node.js command-line programs",

@@ -18,3 +18,3 @@ "keywords": [

"should": ">= 0.0.1",
"sinon": ">= 1.14.1"
"sinon": ">=1.17.1"
},

@@ -21,0 +21,0 @@ "scripts": {

@@ -170,3 +170,3 @@ # Commander.js

.command('search [query]', 'search with optional query')
.command('list', 'list packages installed')
.command('list', 'list packages installed', {isDefault: true})
.parse(process.argv);

@@ -178,2 +178,4 @@ ```

Options can be passed with the call to `.command()`. Specifying `true` for `opts.noHelp` will remove the option from the generated help output. Specifying `true` for `opts.isDefault` will run the subcommand if no other subcommand is specified.
If the program is designed to be installed globally, make sure the executables have proper modes, like `755`.

@@ -271,5 +273,6 @@

## .outputHelp()
## .outputHelp(cb)
Output help information without exiting.
Optional callback cb allows post-processing of help text before it is displayed.

@@ -280,2 +283,3 @@ If you want to display help by default (e.g. if no command was provided), you can use something like:

var program = require('commander');
var colors = require('colors');

@@ -288,9 +292,14 @@ program

if (!process.argv.slice(2).length) {
program.outputHelp();
program.outputHelp(make_red);
}
function make_red(txt) {
return colors.red(txt); //display the help text in red on the console
}
```
## .help()
## .help(cb)
Output help information and exit immediately.
Optional callback cb allows post-processing of help text before it is displayed.

@@ -297,0 +306,0 @@ ## Examples

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