command-line-args
Advanced tools
+2
-2
@@ -9,4 +9,4 @@ 'use strict' | ||
| /* | ||
| enable partial parsing to prevent exceptions being thrown | ||
| if the user sets undefined, mocha-specific options (e.g. --no-colors) | ||
| enable partial parsing to prevent `UNKNOWN_OPTION` exceptions being thrown | ||
| if the user sets mocha-specific options (e.g. --no-colors) | ||
| */ | ||
@@ -13,0 +13,0 @@ const options = commandLineArgs({ name: 'value', type: Number }, { partial: true }) |
+29
-0
@@ -89,2 +89,31 @@ [](https://www.npmjs.org/package/command-line-args) | ||
| ### Partial parsing | ||
| By default, if the user sets an option without a valid [definition](#exp_module_definition--OptionDefinition) an `UNKNOWN_OPTION` exception is thrown. However, in some cases you may only be interested in a subset of the options wishing to pass the remainder to another library. See [here](https://github.com/75lb/command-line-args/blob/master/example/mocha.js) for a example showing where this might be necessary. | ||
| To enable partial parsing, set `partial: true` in the method options: | ||
| ```js | ||
| const optionDefinitions = [ | ||
| { name: 'value', type: Number } | ||
| ] | ||
| const options = commandLineArgs(optionDefinitions, { partial: true }) | ||
| ``` | ||
| Now, should any unknown args be passed at the command line: | ||
| ``` | ||
| $ example --milk --value 2 --bread cheese | ||
| ``` | ||
| They will be returned in the `_unknown` property of the `commandLineArgs` output with no exceptions thrown: | ||
| ```js | ||
| { | ||
| value: 2, | ||
| _unknown: [ '--milk', '--bread', 'cheese'] | ||
| } | ||
| ``` | ||
| ## Install | ||
@@ -91,0 +120,0 @@ |
@@ -11,3 +11,3 @@ 'use strict' | ||
| * | ||
| * By default, an exception is thrown if the user sets an unknown option (one without a valid [definition](#exp_module_definition--OptionDefinition)). To enable __partial parsing__, invoke `commandLineArgs` with the `partial` option - all unknown arguments will be returned in the additional `_unknown` property of the output. | ||
| * By default, an exception is thrown if the user sets an unknown option (one without a valid [definition](#exp_module_definition--OptionDefinition)). To enable __partial parsing__, invoke `commandLineArgs` with the `partial` option - all unknown arguments will be returned in the `_unknown` property. | ||
| * | ||
@@ -14,0 +14,0 @@ * |
+1
-1
| { | ||
| "name": "command-line-args", | ||
| "version": "4.0.0", | ||
| "version": "4.0.1", | ||
| "description": "A mature, feature-complete library to parse command-line options.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/75lb/command-line-args.git", |
+30
-1
@@ -89,2 +89,31 @@ [](https://www.npmjs.org/package/command-line-args) | ||
| ### Partial parsing | ||
| By default, if the user sets an option without a valid [definition](#exp_module_definition--OptionDefinition) an `UNKNOWN_OPTION` exception is thrown. However, in some cases you may only be interested in a subset of the options wishing to pass the remainder to another library. See [here](https://github.com/75lb/command-line-args/blob/master/example/mocha.js) for a example showing where this might be necessary. | ||
| To enable partial parsing, set `partial: true` in the method options: | ||
| ```js | ||
| const optionDefinitions = [ | ||
| { name: 'value', type: Number } | ||
| ] | ||
| const options = commandLineArgs(optionDefinitions, { partial: true }) | ||
| ``` | ||
| Now, should any unknown args be passed at the command line: | ||
| ``` | ||
| $ example --milk --value 2 --bread cheese | ||
| ``` | ||
| They will be returned in the `_unknown` property of the `commandLineArgs` output with no exceptions thrown: | ||
| ```js | ||
| { | ||
| value: 2, | ||
| _unknown: [ '--milk', '--bread', 'cheese'] | ||
| } | ||
| ``` | ||
| ## Install | ||
@@ -102,3 +131,3 @@ | ||
| By default, an exception is thrown if the user sets an unknown option (one without a valid [definition](#exp_module_definition--OptionDefinition)). To enable __partial parsing__, invoke `commandLineArgs` with the `partial` option - all unknown arguments will be returned in the additional `_unknown` property of the output. | ||
| By default, an exception is thrown if the user sets an unknown option (one without a valid [definition](#exp_module_definition--OptionDefinition)). To enable __partial parsing__, invoke `commandLineArgs` with the `partial` option - all unknown arguments will be returned in the `_unknown` property. | ||
@@ -105,0 +134,0 @@ **Kind**: Exported function |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
78085
2.42%375
8.38%