-
Notifications
You must be signed in to change notification settings - Fork 123
Add new type 'number' #5
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,6 +176,20 @@ describe('yargs-parser', function () { | |
x.should.be.a('string').and.equal('56') | ||
}) | ||
|
||
it('should default numbers to undefined', function () { | ||
var n = parser([ '-n' ], { | ||
number: ['n'] | ||
}).n | ||
expect(n).to.equal(undefined) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nexdrew what are your thoughts about defaulting a number to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. defaulting to |
||
}) | ||
|
||
it('should default number to NaN if value is not a valid number', function () { | ||
var n = parser([ '-n', 'string' ], { | ||
number: ['n'] | ||
}).n | ||
expect(n).to.equal(NaN) | ||
}) | ||
|
||
// Fixes: https://github.com/bcoe/yargs/issues/68 | ||
it('should parse flag arguments with no right-hand-value as strings, if defined as strings', function () { | ||
var s = parser([ '-s' ], { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can get rid of this check, it won't actually do anything, instead update:
https://github.com/yargs/yargs-parser/blob/master/index.js#L315
To be something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bcoe @maxrimue got this going so far: