commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benedikt Ritter (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (CLI-266) HelpFormatter#setOptionComparator(null) doesn't display the values in inserted order
Date Tue, 21 Jun 2016 20:27:57 GMT

     [ https://issues.apache.org/jira/browse/CLI-266?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Benedikt Ritter resolved CLI-266.
---------------------------------
       Resolution: Fixed
    Fix Version/s: 1.4

{code}
$ svn ci -m "CLI-266: HelpFormatter.setOptionComparator(null) doesn't display the values in
inserted order. Thank you to Ravi Teja. This also closes #6 from GitHub."
Sending        src/changes/changes.xml
Sending        src/main/java/org/apache/commons/cli/OptionGroup.java
Sending        src/main/java/org/apache/commons/cli/Options.java
Adding         src/test/java/org/apache/commons/cli/bug/BugCLI266Test.java
Transmitting file data ....done
Committing transaction...
Committed revision 1749596.
{code}

Thank you!

> HelpFormatter#setOptionComparator(null) doesn't display the values in inserted order
> ------------------------------------------------------------------------------------
>
>                 Key: CLI-266
>                 URL: https://issues.apache.org/jira/browse/CLI-266
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: CLI-1.x, Help formatter
>    Affects Versions: 1.3.1
>         Environment: Windows
>            Reporter: Ravi Teja
>            Assignee: Benedikt Ritter
>              Labels: easyfix
>             Fix For: 1.4
>
>
> {code:java}
> OptionGroup group = new OptionGroup();
> Option h = Option.builder("h").build();
> Option s = Option.builder("s").build();
> Option b = Option.builder("b").build();
> Option t = Option.builder("t").build();
> group.addOption(h)
>     .addOption(s)
>     .addOption(b)
>     .addOption(t);
> Options options = new Options();
> options.addOptionGroup(group);
> options.addOption(Option.builder("o").build());
> HelpFormatter formatter = new HelpFormatter();
> formatter.setOptionComparator(null);
> formatter.printHelp("cmd", "", options, null);
> {code}
> This code does print the options(1. Group, 2. Option "o") in the order of insertion but
the groups order of display is messed up.
> The OptionGroup internally uses a HashMap. If that could be replaced with a *LinkedHashMap*
this issue can be solved.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message