🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

command-line-parser

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

command-line-parser - npm Package Compare versions

Comparing version

to
0.2.10

5

index.js

@@ -19,2 +19,3 @@ // Converts an array of arguments into a key value object

} = {} ) {
return args.reduce( ( argsObjInReduction, arg, index, args ) => {

@@ -52,3 +53,3 @@ const isArgKey = arg.length > 0 && arg[0] === '-';

.trim()
.replace(/(-+|\s+)\w/g, function (g) { return g[g.length - 1].toUpperCase(); });
.replace(/(-+|\s+)\w/g, g => g[g.length - 1].toUpperCase() );
let value ;

@@ -76,3 +77,3 @@ const embeddedValueObject = allowEmbeddedValues && getEmbeddedKeyValue( trimmedKey );

return argsObjInReduction ;
}, {} );
}, { _args: [] } );
};

4

package.json
{
"name": "command-line-parser",
"version": "0.1.10",
"version": "0.2.10",
"description": "Simple lightweight function takes an array of command-line arguments and returns a parsed object",
"main": "command-line-parser.js",
"main": "index.js",
"scripts": {

@@ -7,0 +7,0 @@ "test": "./node_modules/.bin/mocha --reporter spec"

@@ -30,3 +30,5 @@ # command-line-parser

```
const argsObj = require('command-line-parser')({ booleanKeys: [ 'foo' ] });
const argsObj = require('command-line-parser')({
booleanKeys: [ 'foo' ]
});
```

@@ -39,2 +41,7 @@ A key with multiple leading dashes such as ```--debug``` will be the same as ```-debug``` (with the exception of overriding the optional argument ```allowKeyGrouping``` described below).

To avoid any arguments intended for ```_args``` from becoming the unintentional value of a preceding boolean key, either specify that boolean key in ```booleanKeys``` of config, or follow that boolean key with a placeholder argument such as a single ```-``` or double dash ```--``` on the command line.
```
node ./myscript.js -d -- foo1 foo2 foo3
```
### Embedding numerical values within keys

@@ -51,3 +58,5 @@ Instead of having to separate a numerical argument from its key:

```
const argsObj = require('command-line-parser')({ allowEmbeddedValues: true });
const argsObj = require('command-line-parser')({
allowEmbeddedValues: true
});
```

@@ -67,3 +76,5 @@ to give the result

```
const argsObj = require('command-line-parser')({ allowKeyGrouping: true });
const argsObj = require('command-line-parser')({
allowKeyGrouping: true
});
```

@@ -70,0 +81,0 @@ gives the result

@@ -8,4 +8,4 @@ const should = require('chai').should();

const argsObj = commandLineParser( { args: [] } );
argsObj.should.be.empty;
argsObj.should.be.an('object');
argsObj.should.deep.equal( { _args: [] } ); // nearly should.be.empty
});

@@ -15,4 +15,4 @@

const argsObj = commandLineParser( { args: [ '-', '--', '---' ] } );
argsObj.should.be.empty;
argsObj.should.be.an('object');
argsObj.should.deep.equal( { _args: [] } ); // nearly should.be.empty
});

@@ -19,0 +19,0 @@