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 2 commits into from Jul 23, 2019


Copy link

@juergba juergba commented Jul 16, 2019


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 force-pushed the issue/boolean-narg branch from 1ef8e44 to 6da3487 Jul 17, 2019
@juergba juergba marked this pull request as ready for review Jul 17, 2019
@bcoe bcoe merged commit c5a1db0 into yargs:master Jul 23, 2019
2 checks passed
@juergba juergba deleted the issue/boolean-narg branch Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants