[Pkg-javascript-commits] [node-nopt] 01/03: New upstream version 3.0.6
Tim Potter
tpot at hpe.com
Thu Sep 22 04:00:01 UTC 2016
This is an automated email from the git hooks/post-receive script.
tpot-guest pushed a commit to branch master
in repository node-nopt.
commit 143c2c3fea30ea510b4d0c9f8f8b108d1682f9b0
Author: Tim Potter <tpot at hpe.com>
Date: Tue Sep 20 16:37:15 2016 +1000
New upstream version 3.0.6
---
.travis.yml | 9 +++++++++
LICENSE | 32 ++++++++++++--------------------
README.md | 22 ++++++++++++----------
lib/nopt.js | 3 ++-
package.json | 14 +++++++-------
test/basic.js | 22 ++++++++++++++++++++++
6 files changed, 64 insertions(+), 38 deletions(-)
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..99f2bbf
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,9 @@
+language: node_js
+language: node_js
+node_js:
+ - '0.8'
+ - '0.10'
+ - '0.12'
+ - 'iojs'
+before_install:
+ - npm install -g npm at latest
diff --git a/LICENSE b/LICENSE
index 05a4010..19129e3 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,23 +1,15 @@
-Copyright 2009, 2010, 2011 Isaac Z. Schlueter.
-All rights reserved.
+The ISC License
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
+Copyright (c) Isaac Z. Schlueter and Contributors
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/README.md b/README.md
index 5aba088..f21a4b3 100644
--- a/README.md
+++ b/README.md
@@ -5,9 +5,10 @@ The Wrong Way is to sit down and write an option parser. We've all done
that.
The Right Way is to write some complex configurable program with so many
-options that you go half-insane just trying to manage them all, and put
-it off with duct-tape solutions until you see exactly to the core of the
-problem, and finally snap and write an awesome option parser.
+options that you hit the limit of your frustration just trying to
+manage them all, and defer it with duct-tape solutions until you see
+exactly to the core of the problem, and finally snap and write an
+awesome option parser.
If you want to write an option parser, don't write an option parser.
Write a package manager, or a source control system, or a service
@@ -28,7 +29,8 @@ nice option parser.
, "bloo" : [ "big", "medium", "small" ]
, "flag" : Boolean
, "pick" : Boolean
- , "many" : [String, Array]
+ , "many1" : [String, Array]
+ , "many2" : [path]
}
, shortHands = { "foofoo" : ["--foo", "Mr. Foo"]
, "b7" : ["--bar", "7"]
@@ -77,11 +79,11 @@ $ node my-program.js --baz b/a/z # known paths are resolved.
# values, and will always be an array. The other types provided
# specify what types are allowed in the list.
-$ node my-program.js --many 1 --many null --many foo
-{ many: ["1", "null", "foo"] }
+$ node my-program.js --many1 5 --many1 null --many1 foo
+{ many1: ["5", "null", "foo"] }
-$ node my-program.js --many foo
-{ many: ["foo"] }
+$ node my-program.js --many2 foo --many2 bar
+{ many2: ["/path/to/foo", "path/to/bar"] }
```
Read the tests at the bottom of `lib/nopt.js` for more examples of
@@ -137,8 +139,8 @@ config object and remove its invalid properties.
## Error Handling
-By default, nopt outputs a warning to standard error when invalid
-options are found. You can change this behavior by assigning a method
+By default, nopt outputs a warning to standard error when invalid values for
+known options are found. You can change this behavior by assigning a method
to `nopt.invalidHandler`. This method will be called with
the offending `nopt.invalidHandler(key, val, types)`.
diff --git a/lib/nopt.js b/lib/nopt.js
index 5309a00..97707e7 100644
--- a/lib/nopt.js
+++ b/lib/nopt.js
@@ -207,7 +207,8 @@ function validate (data, k, val, type, typeDefs) {
for (var i = 0, l = types.length; i < l; i ++) {
debug("test type %j %j %j", k, val, types[i])
var t = typeDefs[types[i]]
- if (t && type === t.type) {
+ if (t &&
+ ((type && type.name && t.type && t.type.name) ? (type.name === t.type.name) : (type === t.type))) {
var d = {}
ok = false !== t.validate(d, k, val)
val = d[k]
diff --git a/package.json b/package.json
index aa16198..bb2745d 100644
--- a/package.json
+++ b/package.json
@@ -1,22 +1,22 @@
{
"name": "nopt",
- "version": "3.0.1",
+ "version": "3.0.6",
"description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.",
"author": "Isaac Z. Schlueter <i at izs.me> (http://blog.izs.me/)",
"main": "lib/nopt.js",
"scripts": {
"test": "tap test/*.js"
},
- "repository": "http://github.com/isaacs/nopt",
- "bin": "./bin/nopt.js",
- "license": {
- "type": "MIT",
- "url": "https://github.com/isaacs/nopt/raw/master/LICENSE"
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/npm/nopt.git"
},
+ "bin": "./bin/nopt.js",
+ "license": "ISC",
"dependencies": {
"abbrev": "1"
},
"devDependencies": {
- "tap": "~0.4.8"
+ "tap": "^1.2.0"
}
}
diff --git a/test/basic.js b/test/basic.js
index 2f9088c..d399de9 100644
--- a/test/basic.js
+++ b/test/basic.js
@@ -31,6 +31,28 @@ test("Unknown options are not parsed as numbers", function (t) {
t.end()
});
+// https://github.com/npm/nopt/issues/48
+test("Check types based on name of type", function (t) {
+ var parsed = nopt({"parse-me": {name: "Number"}}, null, ['--parse-me=1.20'], 0)
+ t.equal(parsed['parse-me'], 1.2)
+ t.end()
+})
+
+
+test("Missing types are not parsed", function (t) {
+ var parsed = nopt({"parse-me": {}}, null, ['--parse-me=1.20'], 0)
+ //should only contain argv
+ t.equal(Object.keys(parsed).length, 1)
+ t.end()
+})
+
+test("Types passed without a name are not parsed", function (t) {
+ var parsed = nopt({"parse-me": {}}, {}, ['--parse-me=1.20'], 0)
+ //should only contain argv
+ t.equal(Object.keys(parsed).length, 1)
+ t.end()
+})
+
test("other tests", function (t) {
var util = require("util")
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-nopt.git
More information about the Pkg-javascript-commits
mailing list