Comparing version 1.2.0 to 1.3.0
26
index.js
@@ -167,2 +167,3 @@ 'use strict' | ||
result: { _: [] }, | ||
explicit: new Set(), | ||
main: null, | ||
@@ -318,3 +319,3 @@ argv: null, | ||
assertNotDefined(j, name) | ||
j.result[name] = envVal(j, name, val) | ||
set(j, name, envVal(j, name, val)) | ||
addHelpText(j, name, val) | ||
@@ -343,3 +344,3 @@ } | ||
if (!val.alias) | ||
j.result[name] = isList(val) ? [] : val.default | ||
set(j, name, isList(val) ? [] : val.default) | ||
} | ||
@@ -367,3 +368,3 @@ | ||
if (!negate && !val.alias) | ||
j.result[name] = isList(val) ? 0 : (val.default || false) | ||
set(j, name, isList(val) ? 0 : (val.default || false)) | ||
@@ -553,13 +554,10 @@ addHelpText(j, name, val) | ||
if (isOpt(spec)) { | ||
j.result[name].push(val) | ||
set(j, name, j.result[name].concat(val)) | ||
} else { | ||
j.result[name] = j.result[name] || 0 | ||
if (negate) | ||
j.result[name]-- | ||
else | ||
j.result[name]++ | ||
const v = j.result[name] || 0 | ||
set(j, name, negate ? v - 1 : v + 1) | ||
} | ||
} else { | ||
// either flag or opt | ||
j.result[name] = isFlag(spec) ? !negate : val | ||
set(j, name, isFlag(spec) ? !negate : val) | ||
} | ||
@@ -569,3 +567,3 @@ | ||
for (let i in spec.implies) { | ||
j.result[i] = spec.implies[i] | ||
set(j, i, spec.implies[i]) | ||
} | ||
@@ -578,2 +576,3 @@ } | ||
}) | ||
Object.defineProperty(j.result._, 'explicit', { value: j.explicit }) | ||
Object.defineProperty(j.result._, 'parsed', { value: argv }) | ||
@@ -584,2 +583,7 @@ | ||
const set = (j, key, val) => { | ||
j.result[key] = val | ||
j.explicit.add(key) | ||
} | ||
// just parse the arguments and return the result | ||
@@ -586,0 +590,0 @@ const parse = (...sections) => parse_(buildParser(newObj(), sections)).result |
{ | ||
"name": "jackspeak", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "A very strict and proper argument parser.", | ||
@@ -16,3 +16,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"tap": "^12.5.0" | ||
"tap": "^12.5.1" | ||
}, | ||
@@ -19,0 +19,0 @@ "files": [ |
@@ -19,2 +19,11 @@ # jackspeak | ||
Each of the defined flags and options will be set on the result | ||
object, as well as a special `_` array containing all the positional | ||
arguments. `_` also has the following properties: | ||
- `usage` A function that dumps the help output to stdout. | ||
- `explicit` A `Set` containing the names of all arguments that were | ||
explicitly set. | ||
- `parsed` The `argv` array once all aliases have been expanded. | ||
- `usage` String or Array | ||
@@ -21,0 +30,0 @@ |
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
29530
496
393