commander 0.6.1 → 1.0.0

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.
package/History.md CHANGED
@@ -1,4 +1,10 @@
1
1
 
2
+ 1.0.0 / 2012-07-05
3
+ ==================
4
+
5
+ * add support for optional option descriptions
6
+ * add defaulting of `.version()` to package.json's version
7
+
2
8
  0.6.1 / 2012-06-01
3
9
  ==================
4
10
 
package/lib/commander.js CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  /*!
3
2
  * commander
4
3
  * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
@@ -48,7 +47,7 @@ function Option(flags, description) {
48
47
  flags = flags.split(/[ ,|]+/);
49
48
  if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift();
50
49
  this.long = flags.shift();
51
- this.description = description;
50
+ this.description = description || '';
52
51
  }
53
52
 
54
53
  /**
@@ -342,7 +341,12 @@ Command.prototype.parse = function(argv){
342
341
 
343
342
  // guess name
344
343
  if (!this.name) this.name = basename(argv[1]);
345
-
344
+ // guess version
345
+ if (!this._version) {
346
+ try {
347
+ this.version(require('../package.json').version);
348
+ } catch(e) {}
349
+ }
346
350
  // process argv
347
351
  var parsed = this.parseOptions(this.normalize(argv.slice(2)));
348
352
  this.args = parsed.args;
@@ -556,6 +560,7 @@ Command.prototype.unknownOption = function(flag){
556
560
  process.exit(1);
557
561
  };
558
562
 
563
+
559
564
  /**
560
565
  * Set the program version to `str`.
561
566
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commander"
3
- , "version": "0.6.1"
3
+ , "version": "1.0.0"
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>"