-
Notifications
You must be signed in to change notification settings - Fork 118
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
Bug: different result for -x1 and -1x when -x and -1 are both booleans #283
Comments
Quick triage, looks like the issue is in L270-L276: // current letter is an alphabetic character and next value is a number
if (/[A-Za-z]/.test(letters[j]) &&
/^-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
setArg(letters[j], next)
broken = true
break
} Adding a check to see if next is a boolean alias seems to fix it and doesn't break any existing tests. // current letter is an alphabetic character and next value is a number
if (/[A-Za-z]/.test(letters[j]) &&
/^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) &&
checkAllAliases(next, flags.bools) === false) {
setArg(letters[j], next)
broken = true
break
} const parse1 = parser(['-x1'], { boolean: ['x', '1'] })
console.log(parse1)
// { '1': true, _: [], x: true }
const parse2 = parser(['-1x'], { boolean: ['x', '1'] })
console.log(parse2)
// { '1': true, _: [], x: true } |
@QmarkC This solution seems good and could you please make a PR? |
@QmarkC Hi, could you please have a look at this? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What I'm looking for is to both get
{ '1': true, _: [], x: true }
, because-x
and-1
are both boolean switches and1
is NOT just an argument for-x
.The text was updated successfully, but these errors were encountered: