commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ravi Teja (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CLI-266) HelpFormatter#setOptionComparator(null) doesn't display the values in inserted order
Date Thu, 09 Jun 2016 19:22:21 GMT

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

Ravi Teja updated CLI-266:
--------------------------
    Description: 
{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 in the order of insertion but the group is messed up. The
OptionGroup internally uses a HashMap.

If that could be replaced with a *LinkedHashMap* this issue can be solved.

  was:
{code:java}
OptionGroup group = new OptionGroup();
Option h = Option.builder("h").build();
Option s = Option.builder("b").build();
Option b = Option.builder("b").build();
Option t = Option.builder("b").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 in the order of insertion but the group is messed up. The
OptionGroup internally uses a HashMap.

If that could be replaced with a *LinkedHashMap* this issue can be solved.


> 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
>              Labels: easyfix
>
> {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 in the order of insertion but the group 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