In args4j I define options like that:
@Option(name="-host",usage="host to connect")
@Option(name="-port",usage="port of the host")
@Option(name="-idle",usage="idle")
However when help is displayed args4j always uses alphabetically order so it prints
-host - host to connect
-idle - idle
-port - port to connect
This is not convient because I want to display mandatory options first. Also I want to set order of options myself because some options (like host and port) should go together.
How can I control order of options in args4j?
I've found the same question asked 3 years ago but not answered http://markmail.org/message/xce6vitw6miywtos
According to Brian Peasland, v$sort_usage will show more than just disk sorts. The sort segment in v$sort_usage can be temporary tables, open cursors or some temporary LOBs. This script will use v$sort_usage and v$session to show the TEMP tablespace usage for a specific session:
For sorting in the TEMP tablespace, the v$sort_usage view can be queried to see what session is storing temporary segments in the TEMP tablespace: v.* The v$sort_usage will show more than just disk sorts. The sort segment in v$sort_usage can be temporary tables, open cursors or some temporary LOBs.
For sorting in the TEMP tablespace, the v$sort_usage view can be queried to see what session is storing temporary segments in the TEMP tablespace: v$sort_usage v; The v$sort_usage will show more than just disk sorts. The sort segment in v$sort_usage can be temporary tables, open cursors or some temporary LOBs.
You can set the sorting via the ParserProperties and then use that in the CmdLineParser constructor. If you set the OptionSorter to null, the Option order will be preserved:
ParserProperties properties = ParserProperties.defaults();
properties.withOptionSorter(null);
CmdLineParser parser = new CmdLineParser(YOUR_OPTIONS_CLASS, properties);
So in the question's example you will get:
-host - host to connect
-port - port to connect
-idle - idle
You can't with the current Args4j (at least to my knowledge) - but since it's open source I would encourage you to implement it yourself and try to get the patch in the source for newer releases.
From the source: org.kohsuke.args4j.CmdLineParser
:
// for display purposes, we like the arguments in argument order, but the options in alphabetical order
Collections.sort(options, new Comparator<OptionHandler>() {
public int compare(OptionHandler o1, OptionHandler o2) {
return o1.option.toString().compareTo(o2.option.toString());
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With