commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Neidhart (JIRA)" <>
Subject [jira] [Commented] (CLI-217) Optional partial matching for long options
Date Mon, 11 Feb 2013 13:23:12 GMT


Thomas Neidhart commented on CLI-217:

The patch it not correct, consider the following case:

        String[] args = new String[] {

        Options options = new Options();

        CommandLine cl = parser.parse(options, args);
        assertTrue("Confirm --a is set", cl.hasOption("a"));

This would result in the option "ab" being set, but not "a".

A correct patch would do:

 * first check if there is an exact match and use this option
 * if no exact match, get all options which start with this option
 ** compute the longest common substring of all returned options with the specified option
 ** take the option which has the longest common substring
 ** if there are several with equal length, throw an ambiguous option exception

> Optional partial matching for long options
> ------------------------------------------
>                 Key: CLI-217
>                 URL:
>             Project: Commons CLI
>          Issue Type: Improvement
>          Components: Parser
>    Affects Versions: 1.3
>            Reporter: Emmanuel Bourg
>             Fix For: 1.3
>         Attachments: optPartialMatch.patch
> DefaultParser support partial long options (i.e --ver matches --version if there is no
ambiguity), but for some cases it might be necessary to disable this feature.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message