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

parsing args issue if value starts with dash(-) character #142

Closed
kodekracker opened this issue Oct 22, 2018 · 1 comment
Closed

parsing args issue if value starts with dash(-) character #142

kodekracker opened this issue Oct 22, 2018 · 1 comment

Comments

@kodekracker
Copy link

Steps to reproduce

Save this snippet as example.js

var argv = require('yargs-parser')(process.argv.slice(2))
console.log(argv)

If we run the file by passing these arguments, then we are getting expected result of both arguments i.e foo as 33 and bar as hello

$ node example.js --foo=33 --bar "hello"
{ _: [], foo: 33, bar: 'hello' }

But, if we pass bar argument value whose starting character is -, then output changes a lot, and it's also not a expected one

$ node example.js --foo=33 --bar "-hello"
{ _: [],
  foo: 33,
  bar: true,
  h: true,
  e: true,
  l: [ true, true ],
  o: true }

Here, foo argument has correct value but bar argument value is now boolean.

Expected output in both instructions
{ _: [], foo: 33, bar: 'hello' }
@bcoe
Copy link
Member

bcoe commented Dec 25, 2018

closing in favor of #145, please feel free to join the conversation there.

@bcoe bcoe closed this as completed Dec 25, 2018
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

No branches or pull requests

2 participants