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 +6 -0
- package/lib/commander.js +8 -3
- package/package.json +1 -1
package/History.md
CHANGED
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