Comparing version 0.1.4 to 0.1.5
@@ -0,3 +1,9 @@ | ||
0.1.5 / 2012-09-03 | ||
------------------ | ||
* Fix parser #setDefaults method (thanks to @tomxtobin) | ||
0.1.4 / 2012-07-30 | ||
------------------- | ||
------------------ | ||
@@ -4,0 +10,0 @@ * Fixed pseudo-argument support (thanks to @CGamesPlay) |
@@ -131,3 +131,3 @@ /** internal | ||
this._actions.forEach(function (action) { | ||
if (options.indexOf(action.dest) >= 0) { | ||
if (action.dest in options) { | ||
action.defaultValue = options[action.dest]; | ||
@@ -134,0 +134,0 @@ } |
{ | ||
"name" : "argparse", | ||
"description" : "Very powerful CLI arguments parser. Native port of argparse - python's options parsing library", | ||
"version" : "0.1.4", | ||
"version" : "0.1.5", | ||
"keywords" : ["cli", "parser", "argparse", "option", "args"], | ||
@@ -6,0 +6,0 @@ "homepage" : "https://github.com/nodeca/argparse", |
@@ -34,3 +34,3 @@ /*global describe, it, before, after, beforeEach, afterEach*/ | ||
it("shold parse multipe arguments", function(){ | ||
it("should parse multiple arguments", function(){ | ||
parser.addArgument(['--bar' ]); | ||
@@ -42,3 +42,3 @@ args = parser.parseArgs('--foo 5 --bar 6'.split(' ')); | ||
it("shold check argument type", function(){ | ||
it("should check argument type", function(){ | ||
parser.addArgument(['--bar' ], {type:'int'}); | ||
@@ -49,7 +49,7 @@ assert.throws(function () { parser.parseArgs('--bar bar'.split(' '));}); | ||
it("shoud not drop down with empty args(with out positional arguments)", function(){ | ||
it("should not drop down with empty args (without positional arguments)", function(){ | ||
assert.doesNotThrow(function () {parser.parseArgs([]); }); | ||
}); | ||
it("shoud drop down with empty args (positional arguments", function(){ | ||
it("should drop down with empty args (positional arguments)", function(){ | ||
parser.addArgument([ 'baz']); | ||
@@ -68,4 +68,10 @@ assert.throws( | ||
}); | ||
it("should support #setDefaults", function() { | ||
parser.setDefaults({bar: 1}); | ||
args = parser.parseArgs([]); | ||
assert.equal(args.bar, 1); | ||
}); | ||
}); | ||
}); | ||
@@ -14,2 +14,4 @@ /*global describe, it, before, after, beforeEach, afterEach*/ | ||
var args; | ||
var c1; | ||
var c2; | ||
@@ -22,10 +24,10 @@ beforeEach(function() { | ||
}); | ||
var c1 = subparsers.addParser('c1', {aliases:['co']}); | ||
c1 = subparsers.addParser('c1', {aliases:['co']}); | ||
c1.addArgument([ '-f', '--foo' ], {}); | ||
c1.addArgument([ '-b', '--bar' ], {}); | ||
var c2 = subparsers.addParser('c2', {}); | ||
c2 = subparsers.addParser('c2', {}); | ||
c2.addArgument([ '--baz' ], {}); | ||
}); | ||
it("shold store command name", function(){ | ||
it("should store command name", function(){ | ||
args = parser.parseArgs('c1 --foo 5'.split(' ')); | ||
@@ -35,3 +37,3 @@ assert.equal(args.subcommand_name, 'c1'); | ||
it("shold store command arguments", function(){ | ||
it("should store command arguments", function(){ | ||
args = parser.parseArgs('c1 --foo 5 -b4'.split(' ')); | ||
@@ -42,3 +44,3 @@ assert.equal(args.foo, 5); | ||
it("shold have same behavior for alias and original command", function(){ | ||
it("should have same behavior for alias and original command", function(){ | ||
args = parser.parseArgs('c1 --foo 5 -b4'.split(' ')); | ||
@@ -50,3 +52,3 @@ var aliasArgs = parser.parseArgs('co --foo 5 -b4'.split(' ')); | ||
it("shold have different behavior for different commands", function(){ | ||
it("should have different behavior for different commands", function(){ | ||
assert.doesNotThrow(function() {parser.parseArgs('c1 --foo 5 -b4'.split(' ')); }); | ||
@@ -58,3 +60,3 @@ assert.throws(function () {parser.parseArgs('c2 --foo 5 -b4'.split(' ')); }); | ||
it("shoud drop down with 'unknown parser' error if parse unrecognized command", function(){ | ||
it("should drop down with 'unknown parser' error if parse unrecognized command", function(){ | ||
assert.throws( | ||
@@ -66,3 +68,3 @@ function () {parser.parseArgs('command --baz 1'.split(' ')); }, | ||
it("shoud drop down with empty args ('too few arguments' error)", function(){ | ||
it("should drop down with empty args ('too few arguments' error)", function(){ | ||
assert.throws( | ||
@@ -73,3 +75,14 @@ function () {parser.parseArgs([]); }, | ||
}); | ||
it("should support #setDefaults", function() { | ||
c1.setDefaults({spam: 1}); | ||
c2.setDefaults({eggs: 2}); | ||
args = parser.parseArgs(['c1']); | ||
assert.equal(args.spam, 1); | ||
assert.strictEqual(args.eggs, undefined); | ||
args = parser.parseArgs(['c2']); | ||
assert.equal(args.eggs, 2); | ||
assert.strictEqual(args.spam, undefined); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
119082
3079
0