-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Unable to pass a negative number as an argument #385
Comments
Thanks for taking the time to file this! Try it without using |
I ran it as "./target/debug/myapp -x -10` and got the same result. |
Ah ok I misunderstood at first. This is a bug. Thanks! |
Also, for my curiosity did you run it as The way I could fix this bug is by having something like if you set |
Just tried that. Same buggy outcome. Even if that worked it would be a bug. However wrapping things in If I ran it with |
Ok good to know. Also, it'll always parse values to a string, it's up to the consumer to do otherwise. So If you want to pull a number out of a value there is a macro to remove the boiler plate called I'll play with some ideas about this bug though and post back with any updates. |
By using AppSettings::AllowLeadingHyphen values starting with a leading hyphen (such as a negative number) are supported. This setting should be used with caution as it silences certain circumstances which would otherwise be an error (like forgetting a value to an option argument). Closes #385
Closed with #390 (This will be available shortly on 2.x release) |
By using AppSettings::AllowLeadingHyphen values starting with a leading hyphen (such as a negative number) are supported. This setting should be used with caution as it silences certain circumstances which would otherwise be an error (like forgetting a value to an option argument). Closes #385
By using AppSettings::AllowLeadingHyphen values starting with a leading hyphen (such as a negative number) are supported. This setting should be used with caution as it silences certain circumstances which would otherwise be an error (like forgetting a value to an option argument). Closes #385
Here's a simple programme:
It can run when you pass in
10
as an argument:However not if you pass in
-10
as an argument:Clearly if the argument (
x
) takes a value, then the next string in the command line should be treated as that value, and not attempted to be parsed as a argument in it's own right.The text was updated successfully, but these errors were encountered: