我正在使用以下代码为用户显示帮助屏幕
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("asd123", buildOptions());
参数按字典顺序打印。有没有办法按照添加的顺序打印它们?
我正在使用以下代码为用户显示帮助屏幕
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("asd123", buildOptions());
参数按字典顺序打印。有没有办法按照添加的顺序打印它们?
HelpFormatter supports setting a different Comparator, see the javadoc.
Therefore it should be possible to add a new java.util.Comparator which knows about the intended order and set it for the HelpFormatter via
formatter.setOptionComparator(comparator)
Then printHelp()
should use the order that you provide.
If you cannot do that then the only option I see is to file an enhancement request with commons-cli.