Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling "flatten-duplicate-arrays" leads to unexpected results #115

Closed
FM-96 opened this issue Jan 22, 2018 · 2 comments · Fixed by #128
Closed

Disabling "flatten-duplicate-arrays" leads to unexpected results #115

FM-96 opened this issue Jan 22, 2018 · 2 comments · Fixed by #128

Comments

@FM-96
Copy link

FM-96 commented Jan 22, 2018

Calling this example code:

const yargsParser = require('yargs-parser');

const argv = yargsParser(process.argv.slice(2), {
	array: ['arr'],
	configuration: {
		'flatten-duplicate-arrays': false,
	},
});

console.log(JSON.stringify(argv, null, 2));

with these arguments:

node example.js --arr One Two Three --arr Four Five Six --arr Seven Eight Nine --arr Ten Eleven Twelve

I would expect the following output:

{
  "_": [],
  "arr": [
    [
      "One",
      "Two",
      "Three"
    ],
    [
      "Four",
      "Five",
      "Six"
    ],
    [
      "Seven",
      "Eight",
      "Nine"
    ],
    [
      "Ten",
      "Eleven",
      "Twelve"
    ]
  ]
}

However, instead I get this output:

{
  "_": [],
  "arr": [
    [
      [
        [
          "One",
          "Two",
          "Three"
        ],
        [
          "Four",
          "Five",
          "Six"
        ]
      ],
      [
        "Seven",
        "Eight",
        "Nine"
      ]
    ],
    [
      "Ten",
      "Eleven",
      "Twelve"
    ]
  ]
}

This doesn't seem right to me. Is this the expected behaviour? (If so, it is not apparent from the documentation, in my opinion.)

@bcoe
Copy link
Member

bcoe commented Mar 31, 2018

@FM-96 I agree, this behavior seems incorrect to me. Would you be interested in submitting a failing test for this issue? I'd love help digging into a fix if you have time, and feel like contributing to the project.

@FM-96
Copy link
Author

FM-96 commented Jun 28, 2018

Sorry for taking so long to get back to you.

I would be interested, but I don't have the time right now, and I probably won't have time for a few more months.

However, if this is still needed after that, I'd be happy to help!

laggingreflex added a commit to laggingreflex/yargs-parser that referenced this issue Jul 29, 2018
@bcoe bcoe closed this as completed in #128 Oct 6, 2018
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 a pull request may close this issue.

2 participants