Apache Commons CLI - print trailing args in help output
apache-commons-cli, java
Solution
As far as I can tell the only way to display those extra arguments would be to not print the automatically generated usage statement and instead print a custom usage statement like this:
new HelpFormatter().printHelp("mycmd -d <DIR> extra stuff", opts);
or this
new HelpFormatter().printHelp("mycmd [options] extra stuff", opts);
or however you want to format your usage statement.
Problem
I'm using Apache Commons CLI 1.2 to parse a command line that takes options and extra arguments at the end. Ex: `mycmd -d DIR extra stuff` I know how to get 'extra' and 'stuff' using `CommandLine.getArgs()`, but I don't know how to display those extra arguments in my help output. When I make a call like this: ``` new HelpFormatter().printHelp("mycmd", opts, true); ``` I get output like: ``` usage: mycmd -d DIR ``` without the extra arguments. Could someone point me in the right direction?