Incorrectly guessed parameters to boolean options should be arguments to a command.#75
Incorrectly guessed parameters to boolean options should be arguments to a command.#75
Conversation
|
hmm yeah sorry for the delay, I'll take a closer look at this when I get back on monday |
|
I'm uncertain if you already saw the thread for issue #56, which tries to solve this same problem, but the solution that was integrated there doesn't work in all cases. See my comment for more information. On another note, I limited this pull request to just solving the parameter issue and got rid of the test fix. The latter was just a minor bug anyway; let me know if you'd like another pull request for that. |
|
I'd love to see this fixed, is there still interest in this PR? |
|
I will look into this later. |
|
@zhiyelee Any updates? We can close this if not. |
|
👍 this issue breaks my tool which acts as a tiny |
|
This Pull Request has not had any activity in over six months. It isn't likely to get acted on due to this report. Feel free to open a new issue if it comes up again, with new information and renewed interest. Thank you for your contributions. |
To illustrate the issue, consider the simple command below that prints the string it is given. Call this file cmd.js:
When run without any options, it works fine. The problem arises when the
-eor--exampleboolean option is provided before the input<str>, like so:Even though
-eis a boolean option, "hello" is guessed to be its argument in thelib/commander.json line 504:The "hello" argument is then ignored, which makes the command fail.
I have fixed this issue in the latest commit below by reinserting incorrectly guessed option parameters back into the arguments array for a command. Let me know if you have any questions about the code and if there any changes I need to make.
I also noticed that the date test in
test.prompt.jswas failing. It seems to be that this line:was acting up even though
actualwas indeed an instance ofDate. In fact, I changed it to:and it still failed. As a result, I modified the test to use
should.equal(true)instead, like so:and it passed.
Update: I've omitted the test fix above to make this pull request focus on just one issue. Let me know if you'd like another pull request for the tests; it's just a minor bug anyway.
I've been using commander.js for one of my personal projects and have been pleased with its robustness. I'd love to fix these issues and give back. Don't hesitate if you have any questions or need me to modify something.