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

Default value should be used when the flag is specified with no value #144

Closed
sindresorhus opened this issue Nov 5, 2018 · 1 comment · Fixed by #156
Closed

Default value should be used when the flag is specified with no value #144

sindresorhus opened this issue Nov 5, 2018 · 1 comment · Fixed by #156
Labels

Comments

@sindresorhus
Copy link
Member

Actual:

yargs(['--foo'], {number: ['foo'], default: {foo: 1}});
//=> { _: [], foo: undefined }

Expected:

yargs(['--foo'], {number: ['foo'], default: {foo: 1}});
//=> { _: [], foo: 1 }

Applies to string and number.

Alternatively, it could throw, since --foo is technically an incorrect value, but that might be too opinionated for yargs-parser.

@bcoe
Copy link
Member

bcoe commented Jan 29, 2019

@sindresorhus please take + [email protected] for a spin, it will now use default values if no right-hand side is provided to option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants