-
Notifications
You must be signed in to change notification settings - Fork 43
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
Arguments parsed to numbers incorrectly. #24
Comments
FWIW, jQuery did something like this at one point trying to make their |
Just specify it to be a string by providing |
@michaelficarra In this case, these are unexpected arguments. |
If unexpected were always stored as strings (maybe an option could be added to enable this) then it could be up to the end-user how they wanted to coerce or parse that string value. Which would solve both problems, I think. |
Yes, I could agree with that. |
This is how I'd do it. Create an option whereby a "reviver" method (like |
I could see adding a type that preserves trailing/leading zeroes like you describe. It shoudln't be too hard to do in your app with a custom type, but you'll probably have to look at the nopt and/or npm source to see how to go about it. Doc patch welcome. |
I'm talking about unexpected arguments. |
Oh, right. Sure, patch welcome. |
Please, no additional options. Just unconditionally treat unexpected values as strings. |
I know this is going to be a little bit subjective, but perhaps you can help.
It's hard to pass a version number to nopt like
-r=1.10
because it will treat that value as the number1.1
and not the string"1.10"
. This can be worked around by prefixing it like-r=v1.10
but it's inconvenient to have to strip out the leadingv
in that case if you don't need it.Would it be possible for nopt to check to see if the value, once converted to a number and then back to a string matches the original string, Eg.
What nopt currently does is something more like this:
Here's an example of this "bug" in action:
The text was updated successfully, but these errors were encountered: