Skip to content

Fix: "duplicate-arguments-array" should not interfere with "option.nargs" - #164

Merged
bcoe merged 1 commit into
yargs:masterfrom
juergba:issue/118
Jun 7, 2019
Merged

bcoe merged 1 commit into
yargs:masterfrom
juergba:issue/118

Conversation

@juergba

@juergba juergba commented Mar 23, 2019

Copy link
Copy Markdown
Contributor

Description

#closes #118

var args = parse(
    'foo -p x y', {
        narg: { p: 2 },
        configuration: {
            'duplicate-arguments-array': false,
        }
    }
);
console.log(args);         //  { _: [ 'foo' ], p: 'y' }    <== incorrect

the correct output should be:

  • 'foo -p x y' => { _: [ 'foo' ], p: [ 'x', 'y' ] }
  • 'foo -p x y -p a b' => { _: [ 'foo' ], p: [ 'a', 'b' ] }
  • 'foo -p x y z -p a b c' => { _: [ 'foo' ], p: [ 'a', 'b', 'c' ] }

Description of change

  • fix setKey(): nargs has higher priority than duplicate
  • add one test

@bcoe
bcoe merged commit 47ccb0b into yargs:master Jun 7, 2019
@juergba
juergba deleted the issue/118 branch June 8, 2019 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

odd behavior of narg:2 versus duplicate-arguments-array:false

2 participants