command-line-args
Advanced tools
Comparing version 5.0.0 to 5.0.1
@@ -9,3 +9,3 @@ <a name="module_command-line-args"></a> | ||
Parsing is strict by default - an exception is thrown if the user sets an unknown value or option (one without a valid [definition](https://github.com/75lb/command-line-args/blob/master/doc/option-definition.md)). To be more permissive, enabling [partial mode](https://github.com/75lb/command-line-args/wiki/Partial-mode-example) will return known options as usual and return unknown arguments in a separate `_unknown` property. | ||
Parsing is strict by default - an exception is thrown if the user sets a singular option more than once or sets an unknown value or option (one without a valid [definition](https://github.com/75lb/command-line-args/blob/master/doc/option-definition.md)). To be more permissive, enabling [partial](https://github.com/75lb/command-line-args/wiki/Partial-mode-example) or [stopAtFirstUnknown](https://github.com/75lb/command-line-args/wiki/stopAtFirstUnknown) modes will return known options in the usual manner while collecting unknown arguments in a separate `_unknown` property. | ||
@@ -15,5 +15,5 @@ **Kind**: Exported function | ||
- `UNKNOWN_OPTION` If `options.partial` is false and the user set an undefined option. The unknown option name is stored at `err.optionName`. | ||
- `UNKNOWN_VALUE` If `options.partial` is false and the user set a value unaccounted for by an option. | ||
- `ALREADY_SET` If a user sets a singular, non-multiple option more than once. | ||
- `UNKNOWN_OPTION` If `options.partial` is false and the user set an undefined option. The `err.optionName` property contains the arg that specified an unknown option, e.g. `--one`. | ||
- `UNKNOWN_VALUE` If `options.partial` is false and the user set a value unaccounted for by an option definition. The `err.value` property contains the unknown value, e.g. `5`. | ||
- `ALREADY_SET` If a user sets a singular, non-multiple option more than once. The `err.optionName` property contains the option name that has already been set, e.g. `one`. | ||
- `INVALID_DEFINITIONS` | ||
@@ -20,0 +20,0 @@ - If an option definition is missing the required `name` property |
@@ -7,10 +7,10 @@ <a name="module_option-definition"></a> | ||
* [OptionDefinition](#exp_module_option-definition--OptionDefinition) ⏏ | ||
* [.name](#module_option-definition--OptionDefinition.OptionDefinition+name) : <code>string</code> | ||
* [.type](#module_option-definition--OptionDefinition.OptionDefinition+type) : <code>function</code> | ||
* [.alias](#module_option-definition--OptionDefinition.OptionDefinition+alias) : <code>string</code> | ||
* [.multiple](#module_option-definition--OptionDefinition.OptionDefinition+multiple) : <code>boolean</code> | ||
* [.lazyMultiple](#module_option-definition--OptionDefinition.OptionDefinition+lazyMultiple) : <code>boolean</code> | ||
* [.defaultOption](#module_option-definition--OptionDefinition.OptionDefinition+defaultOption) : <code>boolean</code> | ||
* [.defaultValue](#module_option-definition--OptionDefinition.OptionDefinition+defaultValue) : <code>\*</code> | ||
* [.group](#module_option-definition--OptionDefinition.OptionDefinition+group) : <code>string</code> \| <code>Array.<string></code> | ||
* [.name](#module_option-definition--OptionDefinition+name) : <code>string</code> | ||
* [.type](#module_option-definition--OptionDefinition+type) : <code>function</code> | ||
* [.alias](#module_option-definition--OptionDefinition+alias) : <code>string</code> | ||
* [.multiple](#module_option-definition--OptionDefinition+multiple) : <code>boolean</code> | ||
* [.lazyMultiple](#module_option-definition--OptionDefinition+lazyMultiple) : <code>boolean</code> | ||
* [.defaultOption](#module_option-definition--OptionDefinition+defaultOption) : <code>boolean</code> | ||
* [.defaultValue](#module_option-definition--OptionDefinition+defaultValue) : <code>\*</code> | ||
* [.group](#module_option-definition--OptionDefinition+group) : <code>string</code> \| <code>Array.<string></code> | ||
@@ -23,3 +23,3 @@ <a name="exp_module_option-definition--OptionDefinition"></a> | ||
**Kind**: Exported class | ||
<a name="module_option-definition--OptionDefinition.OptionDefinition+name"></a> | ||
<a name="module_option-definition--OptionDefinition+name"></a> | ||
@@ -53,3 +53,3 @@ #### option.name : <code>string</code> | ||
**Kind**: instance property of [<code>OptionDefinition</code>](#exp_module_option-definition--OptionDefinition) | ||
<a name="module_option-definition--OptionDefinition.OptionDefinition+type"></a> | ||
<a name="module_option-definition--OptionDefinition+type"></a> | ||
@@ -91,3 +91,3 @@ #### option.type : <code>function</code> | ||
**Default**: <code>String</code> | ||
<a name="module_option-definition--OptionDefinition.OptionDefinition+alias"></a> | ||
<a name="module_option-definition--OptionDefinition+alias"></a> | ||
@@ -111,3 +111,3 @@ #### option.alias : <code>string</code> | ||
**Kind**: instance property of [<code>OptionDefinition</code>](#exp_module_option-definition--OptionDefinition) | ||
<a name="module_option-definition--OptionDefinition.OptionDefinition+multiple"></a> | ||
<a name="module_option-definition--OptionDefinition+multiple"></a> | ||
@@ -132,3 +132,3 @@ #### option.multiple : <code>boolean</code> | ||
**Kind**: instance property of [<code>OptionDefinition</code>](#exp_module_option-definition--OptionDefinition) | ||
<a name="module_option-definition--OptionDefinition.OptionDefinition+lazyMultiple"></a> | ||
<a name="module_option-definition--OptionDefinition+lazyMultiple"></a> | ||
@@ -149,3 +149,3 @@ #### option.lazyMultiple : <code>boolean</code> | ||
**Kind**: instance property of [<code>OptionDefinition</code>](#exp_module_option-definition--OptionDefinition) | ||
<a name="module_option-definition--OptionDefinition.OptionDefinition+defaultOption"></a> | ||
<a name="module_option-definition--OptionDefinition+defaultOption"></a> | ||
@@ -168,3 +168,3 @@ #### option.defaultOption : <code>boolean</code> | ||
**Kind**: instance property of [<code>OptionDefinition</code>](#exp_module_option-definition--OptionDefinition) | ||
<a name="module_option-definition--OptionDefinition.OptionDefinition+defaultValue"></a> | ||
<a name="module_option-definition--OptionDefinition+defaultValue"></a> | ||
@@ -188,3 +188,3 @@ #### option.defaultValue : <code>\*</code> | ||
**Kind**: instance property of [<code>OptionDefinition</code>](#exp_module_option-definition--OptionDefinition) | ||
<a name="module_option-definition--OptionDefinition.OptionDefinition+group"></a> | ||
<a name="module_option-definition--OptionDefinition+group"></a> | ||
@@ -191,0 +191,0 @@ #### option.group : <code>string</code> \| <code>Array.<string></code> |
@@ -11,3 +11,3 @@ 'use strict' | ||
* | ||
* Parsing is strict by default - an exception is thrown if the user sets an unknown value or option (one without a valid [definition](https://github.com/75lb/command-line-args/blob/master/doc/option-definition.md)). To be more permissive, enabling [partial mode](https://github.com/75lb/command-line-args/wiki/Partial-mode-example) will return known options as usual and return unknown arguments in a separate `_unknown` property. | ||
* Parsing is strict by default - an exception is thrown if the user sets a singular option more than once or sets an unknown value or option (one without a valid [definition](https://github.com/75lb/command-line-args/blob/master/doc/option-definition.md)). To be more permissive, enabling [partial](https://github.com/75lb/command-line-args/wiki/Partial-mode-example) or [stopAtFirstUnknown](https://github.com/75lb/command-line-args/wiki/stopAtFirstUnknown) modes will return known options in the usual manner while collecting unknown arguments in a separate `_unknown` property. | ||
* | ||
@@ -21,5 +21,5 @@ * @param {module:definition[]} - An array of [OptionDefinition](https://github.com/75lb/command-line-args/blob/master/doc/option-definition.md) objects | ||
* @returns {object} | ||
* @throws `UNKNOWN_OPTION` If `options.partial` is false and the user set an undefined option. The unknown option name is stored at `err.optionName`. | ||
* @throws `UNKNOWN_VALUE` If `options.partial` is false and the user set a value unaccounted for by an option. | ||
* @throws `ALREADY_SET` If a user sets a singular, non-multiple option more than once. | ||
* @throws `UNKNOWN_OPTION` If `options.partial` is false and the user set an undefined option. The `err.optionName` property contains the arg that specified an unknown option, e.g. `--one`. | ||
* @throws `UNKNOWN_VALUE` If `options.partial` is false and the user set a value unaccounted for by an option definition. The `err.value` property contains the unknown value, e.g. `5`. | ||
* @throws `ALREADY_SET` If a user sets a singular, non-multiple option more than once. The `err.optionName` property contains the option name that has already been set, e.g. `one`. | ||
* @throws `INVALID_DEFINITIONS` | ||
@@ -26,0 +26,0 @@ * - If an option definition is missing the required `name` property |
@@ -41,2 +41,3 @@ 'use strict' | ||
err.value = val | ||
err.optionName = def.name | ||
throw err | ||
@@ -43,0 +44,0 @@ } else if (val === null || val === undefined) { |
{ | ||
"name": "command-line-args", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "A mature, feature-complete library to parse command-line options.", | ||
@@ -31,4 +31,4 @@ "repository": "https://github.com/75lb/command-line-args.git", | ||
"coveralls": "^3.0.0", | ||
"jsdoc-to-markdown": "^3.0.4", | ||
"test-runner": "^0.5.0-1" | ||
"jsdoc-to-markdown": "^4.0.1", | ||
"test-runner": "^0.5.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "dependencies": { |
@@ -53,16 +53,28 @@ [![view on npm](https://img.shields.io/npm/v/command-line-args.svg)](https://www.npmjs.org/package/command-line-args) | ||
Beside the above typical usage, you can use command-line-args to accept more advanced command line syntax forms. | ||
Beside the above typical usage, you can configure command-line-args to accept more advanced syntax forms. | ||
* [Git-style command syntax](https://github.com/75lb/command-line-args/wiki/Implement-command-parsing-(git-style)), for example: | ||
* [Command-based syntax (like git)](https://github.com/75lb/command-line-args/wiki/Implement-command-parsing-(git-style)) in the form: | ||
``` | ||
$ executable <command> [options] | ||
``` | ||
For example. | ||
``` | ||
$ git commit --squash -m This is my commit message | ||
``` | ||
* [Complex docker-style commands containing multiple commands](https://github.com/75lb/command-line-args/wiki/Implement-multiple-command-parsing-(docker-style)), for example: | ||
* [Command and sub-command syntax (like docker)](https://github.com/75lb/command-line-args/wiki/Implement-multiple-command-parsing-(docker-style)) in the form: | ||
``` | ||
$ docker run --detached centos bash -c yum install -y httpd | ||
$ executable <command> [options] <sub-command> [options] | ||
``` | ||
For example. | ||
``` | ||
$ docker run --detached --image centos bash -c yum install -y httpd | ||
``` | ||
## Usage guide generation | ||
@@ -69,0 +81,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
2766
104
109120