[
https://issues.apache.org/jira/browse/CLI-150?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Oliver Heger updated CLI-150:
-----------------------------
Attachment: patchCL150.patch
A proposed solution for this problem. The attached patch changes the
looksLikeOption() method of WriteableCommandLineImpl to not only test for the
prefixes defined for options, but also take the options supported by the group
currently processed into account. So true is returned only if the passed in
string starts with an option prefix and can be processed by the current option.
This is certainly an improvement, however I am not sure whether this really
works in all constellations with deeply nested groups.
> Negative numbers mistaken for options
> -------------------------------------
>
> Key: CLI-150
> URL: https://issues.apache.org/jira/browse/CLI-150
> Project: Commons CLI
> Issue Type: Bug
> Components: CLI-2.x
> Environment: Sun JDK 1.6, Ubuntu 7.04
> Reporter: Dioktos
> Fix For: 2.0
>
> Attachments: BugCLI150Test.java, patchCL150.patch
>
>
> If an option has a negative numerical argument, the parser mistakes it for
> another option and throws an error. For example, consider:
> {{Argument numArg =
> aBuilder.withValidator(NumberValidator.getNumberInstance()).withMinimum(1).withMaximum(1).create();}}
> {{Option numOpt =
> oBuilder.withLongName("num").withArgument(numArg).create();}}
> {{Group options = gBuilder.withOption(numOpt).create();}}
> Then parsing {{--num -0.1}} results in:
> {{Unexpected -0.1 while processing --num}}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.