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

feat: allow not to flatten duplicate array types #71

Merged
merged 2 commits into from
Nov 27, 2016

Conversation

laggingreflex
Copy link
Contributor

@laggingreflex laggingreflex commented Nov 25, 2016

Lets you disable flattening of multiple array type values

yargsParser('-x a b -x c d', {array: ['x]})
// => {x: ['a', 'b', 'c', 'd']} // all flattened
yargsParser('-x a b -x c d', {array: ['x], configuration:{'flatten-duplicate-arrays': false}})
// => {x: [['a', 'b'], ['c', 'd']]} // multiple nested arrays
yargsParser('-x a b', {array: ['x], configuration:{'flatten-duplicate-arrays': false}})
// => {x: ['a', 'b']} // still a flat single array when no duplicates

fixes yargs#688

includes #67

Lets you disable "duplicates" behaviour

```
yargsParser('-x 1 -x 2')
// => {x: [1, 2]}
```
```
yargsParser('-x 1 -x 2', {configuration:{'duplicate-arguments-array': false}})
// => {x: 2}
```
@laggingreflex laggingreflex changed the title Array feat: allow disabling duplicate-arguments-array Nov 25, 2016
@laggingreflex laggingreflex changed the title feat: allow disabling duplicate-arguments-array feat: allow not to flatten duplicate array types Nov 25, 2016
Lets you disable flattening of multiple array type values

```
yargsParser('-x a b -x c d', {array: ['x]})
// => {x: ['a', 'b', 'c', 'd']} // all flattened
```
```
yargsParser('-x a b -x c d', {array: ['x], configuration:{'flatten-duplicate-arrays': false}})
// => {x: [['a', 'b'], ['c', 'd']]} // multiple nested arrays
```
@bcoe
Copy link
Member

bcoe commented Nov 27, 2016

@laggingreflex thanks for the great contributions 👍

@bcoe bcoe merged commit 0f0fb2d into yargs:master Nov 27, 2016
This was referenced Mar 10, 2021
This was referenced Mar 18, 2021
facebook-github-bot referenced this pull request in facebook/flow Apr 8, 2021
Summary:
Bumps [yargs-parser](https://github.com/yargs/yargs-parser) from 5.0.0 to 5.0.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/yargs/yargs-parser/releases">yargs-parser's releases</a>.</em></p>
<blockquote>
<h2>yargs-parser v5.0.1</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>security:</strong> address GHSA-p9pc-299p-vxgp (<a href="https://www.github.com/yargs/yargs-parser/issues/362">https://github.com/facebook/flow/issues/362</a>) (<a href="https://www.github.com/yargs/yargs-parser/commit/1c417bd0b42b09c475ee881e36d292af4fa2cc36">1c417bd</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/yargs/yargs-parser/blob/v5.0.1/CHANGELOG.md">yargs-parser's changelog</a>.</em></p>
<blockquote>
<h1><a href="https://github.com/yargs/yargs-parser/compare/v4.2.1...v5.0.0">5.0.0</a> (2017-02-18)</h1>
<h3>Bug Fixes</h3>
<ul>
<li>environment variables should take precedence over config file (<a href="https://github.com/yargs/yargs-parser/issues/81">https://github.com/facebook/flow/issues/81</a>) (<a href="https://github.com/yargs/yargs-parser/commit/76cee1f">76cee1f</a>)</li>
</ul>
<h3>BREAKING CHANGES</h3>
<ul>
<li>environment variables will now override config files (args, env, config-file, config-object)</li>
</ul>
<p><!-- raw HTML omitted --><!-- raw HTML omitted --></p>
<h3><a href="https://www.github.com/yargs/yargs-parser/compare/v5.0.0...v5.0.1">5.0.1</a> (2021-03-10)</h3>
<h3>Bug Fixes</h3>
<ul>
<li><strong>security:</strong> address GHSA-p9pc-299p-vxgp (<a href="https://www.github.com/yargs/yargs-parser/issues/362">https://github.com/facebook/flow/issues/362</a>) (<a href="https://www.github.com/yargs/yargs-parser/commit/1c417bd0b42b09c475ee881e36d292af4fa2cc36">1c417bd</a>)</li>
</ul>
<h2><a href="https://github.com/yargs/yargs-parser/compare/v4.2.0...v4.2.1">4.2.1</a> (2017-01-02)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>flatten/duplicate regression (<a href="https://github.com/yargs/yargs-parser/issues/75">https://github.com/facebook/flow/issues/75</a>) (<a href="https://github.com/yargs/yargs-parser/commit/68d68a0">68d68a0</a>)</li>
</ul>
<p><!-- raw HTML omitted --><!-- raw HTML omitted --></p>
<h1><a href="https://github.com/yargs/yargs-parser/compare/v4.1.0...v4.2.0">4.2.0</a> (2016-12-01)</h1>
<h3>Bug Fixes</h3>
<ul>
<li>inner objects in configs had their keys appended to top-level key when dot-notation was disabled (<a href="https://github.com/yargs/yargs-parser/issues/72">https://github.com/facebook/flow/issues/72</a>) (<a href="https://github.com/yargs/yargs-parser/commit/0b1b5f9">0b1b5f9</a>)</li>
</ul>
<h3>Features</h3>
<ul>
<li>allow multiple arrays to be provided, rather than always combining (<a href="https://github.com/yargs/yargs-parser/issues/71">https://github.com/facebook/flow/issues/71</a>) (<a href="https://github.com/yargs/yargs-parser/commit/0f0fb2d">0f0fb2d</a>)</li>
</ul>
<p><!-- raw HTML omitted --><!-- raw HTML omitted --></p>
<h1><a href="https://github.com/yargs/yargs-parser/compare/v4.0.2...v4.1.0">4.1.0</a> (2016-11-07)</h1>

</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/yargs/yargs-parser/commit/eab6c039888bd5d51f33dda7a98808564acfa938"><code>eab6c03</code></a> chore: release 5.0.1 (<a href="https://github.com/yargs/yargs-parser/issues/363">https://github.com/facebook/flow/issues/363</a>)</li>
<li><a href="https://github.com/yargs/yargs-parser/commit/1c417bd0b42b09c475ee881e36d292af4fa2cc36"><code>1c417bd</code></a> fix(security): address GHSA-p9pc-299p-vxgp (<a href="https://github.com/yargs/yargs-parser/issues/362">https://github.com/facebook/flow/issues/362</a>)</li>
<li><a href="https://github.com/yargs/yargs-parser/commit/e93a345e1e585ba5df97c1da438673e7f2e8909b"><code>e93a345</code></a> chore: mark release in commit history (<a href="https://github.com/yargs/yargs-parser/issues/361">https://github.com/facebook/flow/issues/361</a>)</li>
<li><a href="https://github.com/yargs/yargs-parser/commit/ee15863f7c62418c4fc92b64c3488778c46833dc"><code>ee15863</code></a> chore: push new package version</li>
<li><a href="https://github.com/yargs/yargs-parser/commit/47742078426f0e4e02aa988062b5fb0fa61182b9"><code>4774207</code></a> fix: back-porting prototype fixes for <em>really</em> old version (<a href="https://github.com/yargs/yargs-parser/issues/271">https://github.com/facebook/flow/issues/271</a>)</li>
<li>See full diff in <a href="https://github.com/yargs/yargs-parser/compare/v5.0.0...v5.0.1">compare view</a></li>
</ul>
</details>
<details>
<summary>Maintainer changes</summary>
<p>This version was pushed to npm by <a href="https://www.npmjs.com/~oss-bot">oss-bot</a>, a new releaser for yargs-parser since your current version.</p>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=yargs-parser&package-manager=npm_and_yarn&previous-version=5.0.0&new-version=5.0.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/facebook/flow/network/alerts).

</details>

Pull Request resolved: #8614

Reviewed By: panagosg7

Differential Revision: D27566668

Pulled By: mroch

fbshipit-source-id: a30210adfd27975cca37d89fc144c05a6d2285a1
noppa referenced this pull request in noppa/flow May 7, 2021
Summary:
Bumps [yargs-parser](https://github.com/yargs/yargs-parser) from 5.0.0 to 5.0.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/yargs/yargs-parser/releases">yargs-parser's releases</a>.</em></p>
<blockquote>
<h2>yargs-parser v5.0.1</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>security:</strong> address GHSA-p9pc-299p-vxgp (<a href="https://www.github.com/yargs/yargs-parser/issues/362">https://github.com/facebook/flow/issues/362</a>) (<a href="https://www.github.com/yargs/yargs-parser/commit/1c417bd0b42b09c475ee881e36d292af4fa2cc36">1c417bd</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/yargs/yargs-parser/blob/v5.0.1/CHANGELOG.md">yargs-parser's changelog</a>.</em></p>
<blockquote>
<h1><a href="https://github.com/yargs/yargs-parser/compare/v4.2.1...v5.0.0">5.0.0</a> (2017-02-18)</h1>
<h3>Bug Fixes</h3>
<ul>
<li>environment variables should take precedence over config file (<a href="https://github.com/yargs/yargs-parser/issues/81">https://github.com/facebook/flow/issues/81</a>) (<a href="https://github.com/yargs/yargs-parser/commit/76cee1f">76cee1f</a>)</li>
</ul>
<h3>BREAKING CHANGES</h3>
<ul>
<li>environment variables will now override config files (args, env, config-file, config-object)</li>
</ul>
<p><!-- raw HTML omitted --><!-- raw HTML omitted --></p>
<h3><a href="https://www.github.com/yargs/yargs-parser/compare/v5.0.0...v5.0.1">5.0.1</a> (2021-03-10)</h3>
<h3>Bug Fixes</h3>
<ul>
<li><strong>security:</strong> address GHSA-p9pc-299p-vxgp (<a href="https://www.github.com/yargs/yargs-parser/issues/362">https://github.com/facebook/flow/issues/362</a>) (<a href="https://www.github.com/yargs/yargs-parser/commit/1c417bd0b42b09c475ee881e36d292af4fa2cc36">1c417bd</a>)</li>
</ul>
<h2><a href="https://github.com/yargs/yargs-parser/compare/v4.2.0...v4.2.1">4.2.1</a> (2017-01-02)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>flatten/duplicate regression (<a href="https://github.com/yargs/yargs-parser/issues/75">https://github.com/facebook/flow/issues/75</a>) (<a href="https://github.com/yargs/yargs-parser/commit/68d68a0">68d68a0</a>)</li>
</ul>
<p><!-- raw HTML omitted --><!-- raw HTML omitted --></p>
<h1><a href="https://github.com/yargs/yargs-parser/compare/v4.1.0...v4.2.0">4.2.0</a> (2016-12-01)</h1>
<h3>Bug Fixes</h3>
<ul>
<li>inner objects in configs had their keys appended to top-level key when dot-notation was disabled (<a href="https://github.com/yargs/yargs-parser/issues/72">https://github.com/facebook/flow/issues/72</a>) (<a href="https://github.com/yargs/yargs-parser/commit/0b1b5f9">0b1b5f9</a>)</li>
</ul>
<h3>Features</h3>
<ul>
<li>allow multiple arrays to be provided, rather than always combining (<a href="https://github.com/yargs/yargs-parser/issues/71">https://github.com/facebook/flow/issues/71</a>) (<a href="https://github.com/yargs/yargs-parser/commit/0f0fb2d">0f0fb2d</a>)</li>
</ul>
<p><!-- raw HTML omitted --><!-- raw HTML omitted --></p>
<h1><a href="https://github.com/yargs/yargs-parser/compare/v4.0.2...v4.1.0">4.1.0</a> (2016-11-07)</h1>

</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/yargs/yargs-parser/commit/eab6c039888bd5d51f33dda7a98808564acfa938"><code>eab6c03</code></a> chore: release 5.0.1 (<a href="https://github.com/yargs/yargs-parser/issues/363">https://github.com/facebook/flow/issues/363</a>)</li>
<li><a href="https://github.com/yargs/yargs-parser/commit/1c417bd0b42b09c475ee881e36d292af4fa2cc36"><code>1c417bd</code></a> fix(security): address GHSA-p9pc-299p-vxgp (<a href="https://github.com/yargs/yargs-parser/issues/362">https://github.com/facebook/flow/issues/362</a>)</li>
<li><a href="https://github.com/yargs/yargs-parser/commit/e93a345e1e585ba5df97c1da438673e7f2e8909b"><code>e93a345</code></a> chore: mark release in commit history (<a href="https://github.com/yargs/yargs-parser/issues/361">https://github.com/facebook/flow/issues/361</a>)</li>
<li><a href="https://github.com/yargs/yargs-parser/commit/ee15863f7c62418c4fc92b64c3488778c46833dc"><code>ee15863</code></a> chore: push new package version</li>
<li><a href="https://github.com/yargs/yargs-parser/commit/47742078426f0e4e02aa988062b5fb0fa61182b9"><code>4774207</code></a> fix: back-porting prototype fixes for <em>really</em> old version (<a href="https://github.com/yargs/yargs-parser/issues/271">https://github.com/facebook/flow/issues/271</a>)</li>
<li>See full diff in <a href="https://github.com/yargs/yargs-parser/compare/v5.0.0...v5.0.1">compare view</a></li>
</ul>
</details>
<details>
<summary>Maintainer changes</summary>
<p>This version was pushed to npm by <a href="https://www.npmjs.com/~oss-bot">oss-bot</a>, a new releaser for yargs-parser since your current version.</p>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=yargs-parser&package-manager=npm_and_yarn&previous-version=5.0.0&new-version=5.0.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/facebook/flow/network/alerts).

</details>

Pull Request resolved: facebook#8614

Reviewed By: panagosg7

Differential Revision: D27566668

Pulled By: mroch

fbshipit-source-id: a30210adfd27975cca37d89fc144c05a6d2285a1
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.

multiple array arguments are all flattened instead of getting a nested array
2 participants