-
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
Unknown option swallows a known one #11
Comments
I agree, that would be better. What about this case?
Should that be:
or
Though it's a bit trickier, I'm tempted to say that the first makes more sense. Ie, an unknown option will not ever take a Thoughts? |
Yes, that would make sense to me; that if you need to handle a -- prefixed value, you need to define the option, and otherwise any -- prefix introduces a new option. |
I've just been bitten by this issue when using Grunt. Any options that Grunt itself doesn't know about are made available to the various tasks, meaning that there are a lot of unknown options being used in the system. As a result of this issue you can only use one --flag and it must be the last argument of the command. I think the general solution of assuming that unknown arguments won't be prefixed with -- is a good one. |
Currently in nopt, any unknown argument must have a |
Here's an example of everything working properly:
So far, so good. However, a mistaken name for the boolean option throws everything off, so if --myflag was mistakenly used instead of --flag, we get this:
Note how the mistyped 'myflag' option has now consumed the --foo option as its value, leaving what was intended as foo's value as part of 'remain'.
Since it can't be determined whether an unknown option is intended to have a value or not, and since nopt is designed to allow for the use of unknown options, it would make sense to check a possible value for an unknown option to see if it may, in fact, be the name of a known option. In the above example, this would mean that 'foo' would be correctly identified as an option name rather than being consumed as a value.
The text was updated successfully, but these errors were encountered: