You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Per Cederberg (JIRA)" <ji...@apache.org> on 2010/11/07 11:17:05 UTC
[jira] Created: (CLI-212) Impossible to print command-line options
in same order as added
Impossible to print command-line options in same order as added
---------------------------------------------------------------
Key: CLI-212
URL: https://issues.apache.org/jira/browse/CLI-212
Project: Commons CLI
Issue Type: Bug
Components: Help formatter
Affects Versions: 1.2
Reporter: Per Cederberg
Using the current HelpFormater and Options classes it is impossible to print command-line options in the same order as they were added.
In some applications this is critical, since option grouping is important for understanding how to use a program. Also, the programmer might have good reasons for adding options in a particular order. The default could remain printing sorted options, however.
Two small changes need to be made to allow this:
1. Change to use LinkedHashMap instead of HashMap in Options class:
private Map shortOpts = new LinkedHashMap(); // keeps original order by default
private Map optionGroups = new LinkedHashMap();
2. Change the "null" formatter option in HelpFormatter to actually skip sorting:
public void setOptionComparator(Comparator comparator)
this.optionComparator = comparator; // allow null values, default ordering
}
Fix #2 above isn't strictly necessary, but would avoid forcing users to create boiler-plate code for this.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] [Resolved] (CLI-212) Print command-line options in same
order as added
Posted by "Emmanuel Bourg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CLI-212?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Emmanuel Bourg resolved CLI-212.
--------------------------------
Resolution: Fixed
This is now fixed on the trunk
> Print command-line options in same order as added
> -------------------------------------------------
>
> Key: CLI-212
> URL: https://issues.apache.org/jira/browse/CLI-212
> Project: Commons CLI
> Issue Type: Improvement
> Components: Help formatter
> Affects Versions: 1.2
> Reporter: Per Cederberg
> Assignee: Emmanuel Bourg
> Priority: Minor
> Fix For: 1.3
>
> Attachments: sort-fix.patch
>
>
> Using the current HelpFormater and Options classes it is impossible to print command-line options in the same order as they were added.
> In some applications this is critical, since option grouping is important for understanding how to use a program. Also, the programmer might have good reasons for adding options in a particular order. The default could remain printing sorted options, however.
> Two small changes need to be made to allow this:
> 1. Change to use LinkedHashMap instead of HashMap in Options class:
> private Map shortOpts = new LinkedHashMap(); // keeps original order by default
> private Map optionGroups = new LinkedHashMap();
> 2. Change the "null" formatter option in HelpFormatter to actually skip sorting:
> public void setOptionComparator(Comparator comparator)
> this.optionComparator = comparator; // allow null values, default ordering
> }
> Fix #2 above isn't strictly necessary, but would avoid forcing users to create boiler-plate code for this.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Updated: (CLI-212) Impossible to print command-line options
in same order as added
Posted by "Per Cederberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CLI-212?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Per Cederberg updated CLI-212:
------------------------------
Attachment: sort-fix.patch
Clarification + patch for required code changes.
> Impossible to print command-line options in same order as added
> ---------------------------------------------------------------
>
> Key: CLI-212
> URL: https://issues.apache.org/jira/browse/CLI-212
> Project: Commons CLI
> Issue Type: Bug
> Components: Help formatter
> Affects Versions: 1.2
> Reporter: Per Cederberg
> Attachments: sort-fix.patch
>
>
> Using the current HelpFormater and Options classes it is impossible to print command-line options in the same order as they were added.
> In some applications this is critical, since option grouping is important for understanding how to use a program. Also, the programmer might have good reasons for adding options in a particular order. The default could remain printing sorted options, however.
> Two small changes need to be made to allow this:
> 1. Change to use LinkedHashMap instead of HashMap in Options class:
> private Map shortOpts = new LinkedHashMap(); // keeps original order by default
> private Map optionGroups = new LinkedHashMap();
> 2. Change the "null" formatter option in HelpFormatter to actually skip sorting:
> public void setOptionComparator(Comparator comparator)
> this.optionComparator = comparator; // allow null values, default ordering
> }
> Fix #2 above isn't strictly necessary, but would avoid forcing users to create boiler-plate code for this.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (CLI-212) Print command-line options in same order
as added
Posted by "Emmanuel Bourg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CLI-212?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Emmanuel Bourg updated CLI-212:
-------------------------------
Priority: Minor (was: Major)
Fix Version/s: 1.3
Issue Type: Improvement (was: Bug)
Summary: Print command-line options in same order as added (was: Impossible to print command-line options in same order as added)
Thank you for the suggestion, that makes sense. I'll add this to the 1.3 release.
> Print command-line options in same order as added
> -------------------------------------------------
>
> Key: CLI-212
> URL: https://issues.apache.org/jira/browse/CLI-212
> Project: Commons CLI
> Issue Type: Improvement
> Components: Help formatter
> Affects Versions: 1.2
> Reporter: Per Cederberg
> Priority: Minor
> Fix For: 1.3
>
> Attachments: sort-fix.patch
>
>
> Using the current HelpFormater and Options classes it is impossible to print command-line options in the same order as they were added.
> In some applications this is critical, since option grouping is important for understanding how to use a program. Also, the programmer might have good reasons for adding options in a particular order. The default could remain printing sorted options, however.
> Two small changes need to be made to allow this:
> 1. Change to use LinkedHashMap instead of HashMap in Options class:
> private Map shortOpts = new LinkedHashMap(); // keeps original order by default
> private Map optionGroups = new LinkedHashMap();
> 2. Change the "null" formatter option in HelpFormatter to actually skip sorting:
> public void setOptionComparator(Comparator comparator)
> this.optionComparator = comparator; // allow null values, default ordering
> }
> Fix #2 above isn't strictly necessary, but would avoid forcing users to create boiler-plate code for this.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.