Socket
Socket
Sign inDemoInstall

commander

Package Overview
Dependencies
0
Maintainers
1
Versions
115
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.1 to 0.5.2

13

History.md
0.6.1 / 2012-06-01
==================
* Added: append (yes or no) on confirmation
* Added: allow node.js v0.7.x
0.6.0 / 2012-04-10
==================
* Added `.prompt(obj, callback)` support. Closes #49
* Added default support to .choose(). Closes #41
* Fixed the choice example
0.5.1 / 2011-12-20

@@ -3,0 +16,0 @@ ==================

50

lib/commander.js

@@ -801,3 +801,3 @@

*
* @param {String} str
* @param {String|Object} str
* @param {Function} fn

@@ -808,4 +808,24 @@ * @api public

Command.prototype.prompt = function(str, fn){
if (/ $/.test(str)) return this.promptSingleLine.apply(this, arguments);
this.promptMultiLine(str, fn);
var self = this;
if ('string' == typeof str) {
if (/ $/.test(str)) return this.promptSingleLine.apply(this, arguments);
this.promptMultiLine(str, fn);
} else {
var keys = Object.keys(str)
, obj = {};
function next() {
var key = keys.shift()
, label = str[key];
if (!key) return fn(obj);
self.prompt(label, function(val){
obj[key] = val;
next();
});
}
next();
}
};

@@ -888,7 +908,8 @@

Command.prototype.confirm = function(str, fn){
Command.prototype.confirm = function(str, fn, verbose){
var self = this;
this.prompt(str, function(ok){
if (!ok.trim()) {
return self.confirm(str, fn);
if (!verbose) str += '(yes or no) ';
return self.confirm(str, fn, true);
}

@@ -913,2 +934,3 @@ fn(parseBool(ok));

* @param {Array} list
* @param {Number|Function} index or fn
* @param {Function} fn

@@ -918,7 +940,17 @@ * @api public

Command.prototype.choose = function(list, fn){
var self = this;
Command.prototype.choose = function(list, index, fn){
var self = this
, hasDefault = 'number' == typeof index;
if (!hasDefault) {
fn = index;
index = null;
}
list.forEach(function(item, i){
console.log(' %d) %s', i + 1, item);
if (hasDefault && i == index) {
console.log('* %d) %s', i + 1, item);
} else {
console.log(' %d) %s', i + 1, item);
}
});

@@ -929,2 +961,4 @@

val = parseInt(val, 10) - 1;
if (hasDefault && isNaN(val)) val = index;
if (null == list[val]) {

@@ -931,0 +965,0 @@ again();

4

package.json
{
"name": "commander"
, "version": "0.5.1"
, "version": "0.5.2"
, "description": "the complete solution for node.js command-line programs"

@@ -12,3 +12,3 @@ , "keywords": ["command", "option", "parser", "prompt", "stdin"]

, "main": "index"
, "engines": { "node": ">= 0.4.x < 0.7.0" }
, "engines": { "node": ">= 0.4.x" }
}

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

# Commander.js

@@ -53,3 +52,3 @@

-v, --version output the version number
-V, --version output the version number
-p, --peppers Add peppers

@@ -146,3 +145,3 @@ -P, --pineapple Add pineappe

-h, --help output usage information
-v, --version output the version number
-V, --version output the version number
-f, --foo enable some foo

@@ -149,0 +148,0 @@ -b, --bar enable some bar

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc