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

Problem parsing number alias #141

Closed
torifat opened this issue Oct 17, 2018 · 2 comments
Closed

Problem parsing number alias #141

torifat opened this issue Oct 17, 2018 · 2 comments

Comments

@torifat
Copy link

torifat commented Oct 17, 2018

Non-number alias

var argv = require("yargs-parser")(process.argv.slice(2), {
  alias: { z: "zero" },
  default: { zero: false }
});

console.log(argv);
$ node example.js --zero
{ _: [], zero: true, z: true }
$ node example.js -z
{ _: [], z: true, zero: true }

Number alias

var argv = require("yargs-parser")(process.argv.slice(2), {
  alias: { 0: "zero" },
  default: { zero: false }
});

console.log(argv);
$ node example.js --zero
{ '0': true, _: [], zero: true }
$ node example.js -0
{ '0': false, _: [ -0 ], zero: false }

For more context check sindresorhus/meow#89

@torifat
Copy link
Author

torifat commented Oct 18, 2018

I tried to create a PR and end up finding:

} else if (arg.match(/^-[^-]+/) && !arg.match(negative)) {

#44

@torifat torifat closed this as completed Oct 18, 2018
@bcoe
Copy link
Member

bcoe commented Dec 25, 2018

@torifat just catching up on old issues, I'm guessing this is because we allow -1, -2, -3, etc, as positional arguments, so it's ambiguous?

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