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

Option values cannot be negative numbers #33

Closed
mojodna opened this issue May 8, 2016 · 1 comment · Fixed by #44
Closed

Option values cannot be negative numbers #33

mojodna opened this issue May 8, 2016 · 1 comment · Fixed by #44

Comments

@mojodna
Copy link

mojodna commented May 8, 2016

It's not currently possible to set option values to negative numbers (w/o using =), as demonstrated in this diff to the tests:

diff --git i/test/yargs-parser.js w/test/yargs-parser.js
index e290110..07d7335 100644
--- i/test/yargs-parser.js
+++ w/test/yargs-parser.js
@@ -116,6 +116,7 @@ describe('yargs-parser', function () {
       '-z', '1e7',
       '-w', '10f',
       '--hex', '0xdeadbeef',
+      '--negative', '-1',
       '789'
     ])
     argv.should.have.property('x', 1234).and.be.a('number')
@@ -123,6 +124,7 @@ describe('yargs-parser', function () {
     argv.should.have.property('z', 1e7).and.be.a('number')
     argv.should.have.property('w', '10f').and.be.a('string')
     argv.should.have.property('hex', 0xdeadbeef).and.be.a('number')
+    argv.should.have.property('negative', -1).and.be.a('number')
     argv.should.have.property('_').and.deep.equal([789])
     argv._[0].should.be.a('number')
   })

I'm actually more interested in being able to parse an array of numbers, some of which may be negative (e.g. --bounds "-180 -90 180 90", possibly even unquoted), but this appears to be the first snag along that path.

@mojodna
Copy link
Author

mojodna commented Aug 8, 2016

Yay, thank you!!

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 a pull request may close this issue.

1 participant