yargs-parser
Advanced tools
Comparing version 8.1.0 to 9.0.0
@@ -5,2 +5,17 @@ # Change Log | ||
<a name="9.0.0"></a> | ||
# [9.0.0](https://github.com/yargs/yargs-parser/compare/v8.1.0...v9.0.0) (2018-01-20) | ||
### Features | ||
* narg arguments no longer consume flag arguments ([#114](https://github.com/yargs/yargs-parser/issues/114)) ([60bb9b3](https://github.com/yargs/yargs-parser/commit/60bb9b3)) | ||
### BREAKING CHANGES | ||
* arguments of form --foo, -abc, will no longer be consumed by nargs | ||
<a name="8.1.0"></a> | ||
@@ -7,0 +22,0 @@ # [8.1.0](https://github.com/yargs/yargs-parser/compare/v8.0.0...v8.1.0) (2017-12-20) |
13
index.js
@@ -305,7 +305,16 @@ var camelCase = require('camelcase') | ||
function eatNargs (i, key, args) { | ||
var ii | ||
var toEat = checkAllAliases(key, flags.nargs) | ||
if (args.length - (i + 1) < toEat) error = Error(__('Not enough arguments following: %s', key)) | ||
// nargs will not consume flag arguments, e.g., -abc, --foo, | ||
// and terminates when one is observed. | ||
var available = 0 | ||
for (ii = i + 1; ii < args.length; ii++) { | ||
if (!args[ii].match(/^-[^0-9]/)) available++ | ||
else break | ||
} | ||
for (var ii = i + 1; ii < (toEat + i + 1); ii++) { | ||
if (available < toEat) error = Error(__('Not enough arguments following: %s', key)) | ||
for (ii = i + 1; ii < (available + i + 1); ii++) { | ||
setArg(key, args[ii]) | ||
@@ -312,0 +321,0 @@ } |
{ | ||
"name": "yargs-parser", | ||
"version": "8.1.0", | ||
"version": "9.0.0", | ||
"description": "the mighty option parser used by yargs", | ||
"main": "index.js", | ||
"scripts": { | ||
"pretest": "standard", | ||
"test": "nyc mocha test/*.js", | ||
"posttest": "standard", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
@@ -34,3 +34,3 @@ "release": "standard-version" | ||
"standard": "^10.0.2", | ||
"standard-version": "^4.3.0-candidate.0" | ||
"standard-version": "^4.3.0" | ||
}, | ||
@@ -37,0 +37,0 @@ "dependencies": { |
45569
727