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

Fix: eatNargs() for 'opt.narg === 0' and boolean typed options #188

Merged
merged 2 commits into from Jul 23, 2019

Conversation

juergba
Copy link
Contributor

@juergba juergba commented Jul 16, 2019

Description

Currently the parser handles opts.narg before opts.array and therefore eatArray() is not restricted by the opts.narg value.

The edge case opt.narg === 0 is handled in a different way since checkAllAliases() returns false instead of value 0. Case opt.narg === 0 should be handled the same way as opt.narg > 0 to keep the distinction between opts.narg and opts.array options clear and clean.

Description of Change

  • checkAllAliases(): fixes case of opt.narg === 0 and returns now 0 instead of false
  • eatNargs(): sets now default values in case of opt.narg === 0

Note: the default value of a string typed option is currently an empty string (defaultForType()).
I would have expected undefined.

@juergba juergba marked this pull request as ready for review July 17, 2019 13:36
@bcoe bcoe merged commit c5a1db0 into yargs:master Jul 23, 2019
@juergba juergba deleted the issue/boolean-narg branch July 23, 2019 19:03
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.

None yet

2 participants