yargs-parser
Advanced tools
Comparing version 5.0.0 to 6.0.0
@@ -5,2 +5,31 @@ # Change Log | ||
<a name="6.0.0"></a> | ||
# [6.0.0](https://github.com/yargs/yargs-parser/compare/v4.2.1...v6.0.0) (2017-05-01) | ||
### Bug Fixes | ||
* environment variables should take precedence over config file ([#81](https://github.com/yargs/yargs-parser/issues/81)) ([76cee1f](https://github.com/yargs/yargs-parser/commit/76cee1f)) | ||
* parsing hints should apply for dot notation keys ([#86](https://github.com/yargs/yargs-parser/issues/86)) ([3e47d62](https://github.com/yargs/yargs-parser/commit/3e47d62)) | ||
### Chores | ||
* upgrade to newest version of camelcase ([#87](https://github.com/yargs/yargs-parser/issues/87)) ([f1903aa](https://github.com/yargs/yargs-parser/commit/f1903aa)) | ||
### Features | ||
* add -- option which allows arguments after the -- flag to be returned separated from positional arguments ([#84](https://github.com/yargs/yargs-parser/issues/84)) ([2572ca8](https://github.com/yargs/yargs-parser/commit/2572ca8)) | ||
* when parsing stops, we now populate "--" by default ([#88](https://github.com/yargs/yargs-parser/issues/88)) ([cd666db](https://github.com/yargs/yargs-parser/commit/cd666db)) | ||
### BREAKING CHANGES | ||
* rather than placing arguments in "_", when parsing is stopped via "--"; we now populate an array called "--" by default. | ||
* camelcase now requires Node 4+. | ||
* environment variables will now override config files (args, env, config-file, config-object) | ||
<a name="5.0.0"></a> | ||
@@ -7,0 +36,0 @@ # [5.0.0](https://github.com/yargs/yargs-parser/compare/v4.2.1...v5.0.0) (2017-02-18) |
13
index.js
@@ -20,3 +20,4 @@ var camelCase = require('camelcase') | ||
'duplicate-arguments-array': true, | ||
'flatten-duplicate-arrays': true | ||
'flatten-duplicate-arrays': true, | ||
'populate--': true | ||
}, opts.configuration) | ||
@@ -26,2 +27,4 @@ var defaults = opts.default || {} | ||
var envPrefix = opts.envPrefix | ||
var notFlagsOption = configuration['populate--'] | ||
var notFlagsArgv = notFlagsOption ? '--' : '_' | ||
var newAliases = {} | ||
@@ -103,2 +106,6 @@ // allow a i18n handler to be passed in, default to a fake one (util.format). | ||
if (notFlagsOption) { | ||
argv[notFlagsArgv] = [] | ||
} | ||
Object.keys(flags.bools).forEach(function (key) { | ||
@@ -296,3 +303,3 @@ setArg(key, !(key in defaults) ? false : defaults[key]) | ||
notFlags.forEach(function (key) { | ||
argv._.push(key) | ||
argv[notFlagsArgv].push(key) | ||
}) | ||
@@ -565,3 +572,3 @@ | ||
var isTypeArray = checkAllAliases(key, flags.arrays) | ||
var isTypeArray = checkAllAliases(keys.join('.'), flags.arrays) | ||
var isValueArray = Array.isArray(value) | ||
@@ -568,0 +575,0 @@ var duplicate = configuration['duplicate-arguments-array'] |
{ | ||
"name": "yargs-parser", | ||
"version": "5.0.0", | ||
"version": "6.0.0", | ||
"description": "the mighty option parser used by yargs", | ||
@@ -33,7 +33,7 @@ "main": "index.js", | ||
"nyc": "^10.0.0", | ||
"standard": "^8.0.0", | ||
"standard": "^10.0.2", | ||
"standard-version": "^4.0.0" | ||
}, | ||
"dependencies": { | ||
"camelcase": "^3.0.0" | ||
"camelcase": "^4.1.0" | ||
}, | ||
@@ -40,0 +40,0 @@ "files": [ |
@@ -14,3 +14,3 @@ # yargs-parser | ||
<img width="250" src="https://github.com/yargs/yargs-parser/blob/master/yargs-logo.png"> | ||
<img width="250" src="https://raw.githubusercontent.com/yargs/yargs-parser/master/yargs-logo.png"> | ||
@@ -76,2 +76,3 @@ ## Example | ||
* `opts.number`: keys should be treated as numbers. | ||
* `opts['--']`: arguments after the end-of-options flag `--` will be set to the `argv.['--']` array instead of being set to the `argv._` array. | ||
@@ -83,2 +84,3 @@ **returns:** | ||
* `_`: an array representing the positional arguments. | ||
* [optional] `--`: an array with arguments after the end-of-options flag `--`. | ||
@@ -106,2 +108,3 @@ ### require('yargs-parser').detailed(args, opts={}) | ||
<a name="configuration"></a> | ||
### Configuration | ||
@@ -254,2 +257,21 @@ | ||
### `populate--` | ||
* default: `true`. | ||
Should unparsed flags be stored in `--` or `_`. | ||
_If disabled:_ | ||
```sh | ||
node example.js a -b -- x y | ||
{ _: [ 'a', 'x', 'y' ], b: true } | ||
``` | ||
_If enabled:_ | ||
```sh | ||
node example.js a -b -- x y | ||
{ _: [ 'a' ], '--': [ 'x', 'y' ], b: true } | ||
``` | ||
## Special Thanks | ||
@@ -256,0 +278,0 @@ |
39971
682
280
+ Addedcamelcase@4.1.0(transitive)
- Removedcamelcase@3.0.0(transitive)
Updatedcamelcase@^4.1.0