On Sep 2, 2009, at 3:10 PM, Michael Heuer wrote:
Jim Jagielski wrote:
There are times when add in -h/--help and want to allow people
to just go ahead and call the app with that option. The rub is, of
course, if there are any required options, in addition to the usage
message they also get a superfluous "Missing required" note as
well...
This is, imo at least, ugly. If the consensus is that this would be
something nice to fix in the 1.x tree (not sure if still an issue in
2.x), I'll open a JIRA and start work.
There is a workaround if you have only one required option:
Options options = ...;
Option requiredOption = ...;
requiredOption.setRequired(false);
Option help = ...;
help.setRequired(false);
OptionGroup requiredOptions = new OptionGroup();
requiredOptions.addOption(required);
requiredOptions.addOption(help);
requiredOptions.setRequired(true);
options.addOptionGroup(requiredOptions);
but this doesn't work if you have more than one required option.
+1
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org