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
2.2.0 isn't compatible any more with parseInt used with default arguments #201
Comments
I ran across this issue too. I've worked around (temporarily I hope) it like this: function myParseInt(string, defaultValue) {
var int = parseInt(string, 10);
if (typeof int == 'number') {
return int;
} else {
return defaultValue;
}
} and then: require('commander').
option('--port <num>', 'Port number to listen on', myParseInt, 9000).
parse([ 'node', 'main.js', '--port=80' ]).
port |
Me too. I think maybe it should be mentioned in doc at least. It took me half hour to figure out what happened. |
At a minimum, the README must be fixed. The examples in it do not run anymore, because: parseInt("6", 2) yields |
I have edited the History.md in 863e73a |
parseInt wasn't working correctly, so I was unable to use a custom port. Found this github issue: tj/commander.js#201. Made a custom function to handle the port option argument and it started working correctly.
Oops, used this as the earliest report and want it open as I am linking to it from multiple places! |
I have proposed a large update to options coverages in README in #953 |
The options coverage in the README has been updated and includes new description of custom option processing, including a working |
This works as expected in 2.1.0, but in 2.2.0
parseInt
is given 9000 as a second argument, which makes it output nonsense.The text was updated successfully, but these errors were encountered: