Comparing version 2020.8.9 to 2020.8.10
@@ -0,1 +1,6 @@ | ||
### 2020.8.10 | ||
* empty or non-string inputs are ignored. | ||
* trim spaces around inputs | ||
### 2020.8.9 | ||
@@ -2,0 +7,0 @@ |
11
index.js
@@ -83,10 +83,15 @@ const parse_arg = (arg) => { | ||
const trim_filter = (input) => input | ||
.filter(a => typeof a === 'string') | ||
.map(s => s.trim()) | ||
.filter(s => s.length) | ||
module.exports = (args = [], alias = []) => { | ||
if(!Array.isArray(args) || !Array.isArray(alias)) | ||
if (!Array.isArray(args) || !Array.isArray(alias)) | ||
throw Error(`expected input to be array(s). Eg clia(process.argv.slice(2),['alias','names'])`) | ||
const parsed = combine_input(args) | ||
const parsed = combine_input(trim_filter(args)) | ||
copy_alias_values(parsed, alias) | ||
copy_alias_values(parsed, trim_filter(alias)) | ||
@@ -93,0 +98,0 @@ return { |
{ | ||
"name": "clia", | ||
"version": "2020.8.9", | ||
"version": "2020.8.10", | ||
"description": "Command line parser and t3st example project", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,3 +18,3 @@ # clia | ||
const conf = clia(process.argv.slice(2)) // in your app | ||
const conf = clia(process.argv.slice(2)) | ||
@@ -37,6 +37,8 @@ // test in your browser on: https://npm.runkit.com/clia | ||
## parsing | ||
## edge cases | ||
If `--` is encountered, it is ignored. All subsequent inputs are treated as arguments. | ||
Empty or non-string inputs are ignored. Spaces are trimmed from inputs. | ||
When `--` is encountered, it is ignored. All subsequent inputs are treated as arguments even if they start with `-`. | ||
An error is thrown when: | ||
@@ -43,0 +45,0 @@ * any argument containts `__proto__` *to prevent prototype pollution* |
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
7709
83
89