commander 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/History.md +5 -0
  2. package/index.js +5 -2
  3. package/package.json +1 -1
package/History.md CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ 1.3.2 / 2013-07-18
3
+ ==================
4
+
5
+ * add support for sub-commands to co-exist with the original command
6
+
2
7
  1.3.1 / 2013-07-18
3
8
  ==================
4
9
 
package/index.js CHANGED
@@ -91,6 +91,7 @@ Option.prototype.is = function(arg){
91
91
  function Command(name) {
92
92
  this.commands = [];
93
93
  this.options = [];
94
+ this._execs = [];
94
95
  this._args = [];
95
96
  this._name = name;
96
97
  }
@@ -155,6 +156,7 @@ Command.prototype.command = function(name, desc){
155
156
  var cmd = new Command(args.shift());
156
157
  if (desc) cmd.description(desc);
157
158
  if (desc) this.executables = true;
159
+ if (desc) this._execs[cmd._name] = true;
158
160
  this.commands.push(cmd);
159
161
  cmd.parseExpectedArgs(args);
160
162
  cmd.parent = this;
@@ -374,8 +376,9 @@ Command.prototype.parse = function(argv){
374
376
 
375
377
  var result = this.parseArgs(this.args, parsed.unknown);
376
378
 
377
- // executable sub-commands, skip .parseArgs()
378
- if (this.executables) return this.executeSubCommand(argv, args, parsed.unknown);
379
+ // executable sub-commands
380
+ var name = result.args[0];
381
+ if (this._execs[name]) return this.executeSubCommand(argv, args, parsed.unknown);
379
382
 
380
383
  return result;
381
384
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commander"
3
- , "version": "1.3.1"
3
+ , "version": "1.3.2"
4
4
  , "description": "the complete solution for node.js command-line programs"
5
5
  , "keywords": ["command", "option", "parser", "prompt", "stdin"]
6
6
  , "author": "TJ Holowaychuk <tj@vision-media.ca>"