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.

   michael


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to