Comparing version 1.3.1 to 1.3.2
38
index.js
@@ -158,2 +158,3 @@ 'use strict' | ||
// result: parsed object passed to main function and returned | ||
// implies: all the implied variable values (set last) | ||
// } | ||
@@ -172,2 +173,3 @@ const jack = (...sections) => execute(parse_(buildParser(newObj(), sections))) | ||
env: null, | ||
implies: {}, | ||
[usageMemo]: false, | ||
@@ -325,3 +327,7 @@ }) | ||
assertNotDefined(j, name) | ||
set(j, name, envVal(j, name, val)) | ||
const e = envVal(j, name, val) | ||
if (Object.prototype.hasOwnProperty.call(j.env, name)) | ||
set(j, name, val, e) | ||
else | ||
j.result[name] = e | ||
addHelpText(j, name, val) | ||
@@ -350,3 +356,3 @@ } | ||
if (!val.alias) | ||
set(j, name, isList(val) ? [] : val.default) | ||
j.result[name] = isList(val) ? [] : val.default | ||
} | ||
@@ -374,3 +380,3 @@ | ||
if (!negate && !val.alias) | ||
set(j, name, isList(val) ? 0 : (val.default || false)) | ||
j.result[name] = isList(val) ? 0 : (val.default || false) | ||
@@ -386,2 +392,3 @@ addHelpText(j, name, val) | ||
hidden: val.hidden, | ||
implies: val.implies, | ||
...(val.negate || {}), | ||
@@ -561,19 +568,18 @@ [_list]: isList(val) | ||
if (isOpt(spec)) { | ||
set(j, name, j.result[name].concat(val)) | ||
set(j, name, spec, j.result[name].concat(val)) | ||
} else { | ||
const v = j.result[name] || 0 | ||
set(j, name, negate ? v - 1 : v + 1) | ||
set(j, name, spec, negate ? v - 1 : v + 1) | ||
} | ||
} else { | ||
// either flag or opt | ||
set(j, name, isFlag(spec) ? !negate : val) | ||
set(j, name, spec, isFlag(spec) ? !negate : val) | ||
} | ||
if (spec.implies) { | ||
for (let i in spec.implies) { | ||
set(j, i, spec.implies[i]) | ||
} | ||
} | ||
} | ||
for (let i in j.implies) | ||
for (let k in j.implies[i]) | ||
j.result[k] = j.implies[i][k] | ||
Object.defineProperty(j.result._, 'usage', { | ||
@@ -588,5 +594,11 @@ value: () => console.log(usage(j)) | ||
const set = (j, key, val) => { | ||
const set = (j, key, spec, val) => { | ||
j.result[key] = val | ||
j.explicit.add(key) | ||
if (spec && spec.implies) { | ||
if (!val) | ||
delete j.implies[key] | ||
else | ||
j.implies[key] = spec.implies | ||
} | ||
} | ||
@@ -593,0 +605,0 @@ |
{ | ||
"name": "jackspeak", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "A very strict and proper argument parser.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
29924
512