Socket
Socket
Sign inDemoInstall

command-line-args

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

command-line-args - npm Package Compare versions

Comparing version 4.0.0 to 4.0.1

4

example/mocha.js

@@ -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 })

@@ -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 @@ *

{
"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",

@@ -89,2 +89,31 @@ [![view on npm](http://img.shields.io/npm/v/command-line-args.svg)](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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc