Skip to content

Commit efa6c52

Browse files
committed
v0.2.2
Bug fixes: * fix error when showing help information by default * fix typos in package manifest * update dependencies
2 parents 22485fd + 7233993 commit efa6c52

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function Parser(stdout) {
7878
this._version = "0.0.0";
7979
this._epilog = null;
8080
this._commands = { };
81-
this._default = this.showHelp;
81+
this._default = this.showHelp.bind(this);
8282
this._width = 0;
8383
this._out = isFunction(stdout) ? stdout : console.log;
8484
this.option("help", "show this help information", this.showHelp.bind(this));
@@ -178,7 +178,7 @@ Parser.prototype.parse = function(cmds) {
178178
var args = isString(cmds) ? cmds.split(" ") : processArgv();
179179
var context = { };
180180
var command = args[0];
181-
if (command === undefined || command[0] === "-") {
181+
if (command === undefined || command === "" || command[0] === "-") {
182182
context = argv(args);
183183
context._option = "default";
184184
this._default.apply(context, []);

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "simple-argparse",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"description": "Simple Argument parser for Command-line Applications",
5-
"homepage": "https://github.com/forfuture-dev/node-simple-argparse",
5+
"homepage": "https://github.com/forfutureLLC/node-simple-argparse",
66
"license": "MIT",
77
"repository": {
88
"type": "git",
@@ -21,7 +21,7 @@
2121
"author": "GochoMugo <mugo@forfuture.co.ke>",
2222
"main": "index.js",
2323
"dependencies": {
24-
"minimist": "^1.1.1"
24+
"minimist": "^1.1.2"
2525
},
2626
"devDependencies": {
2727
"coveralls": "^2.11.3",

test/test.parser.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ describe("Parser", function() {
202202
});
203203
parser.showHelp();
204204
});
205+
206+
it("show help information as the default option", function(done) {
207+
new Parser(function(out) {
208+
out.should.containEql("just simple");
209+
done();
210+
}).option("simple", "just simple", function() { })
211+
.parse("");
212+
});
205213
});
206214

207215

0 commit comments

Comments
 (0)