commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <>
Subject Re: CLI : OptionBuilder method isRequired() Question
Date Fri, 27 Jun 2003 16:27:57 GMT
On Fri, 2003-06-27 at 12:24, Hainer, Neil wrote:
> How can you implement isRequired() for some options but still allow a user to only enter
the option "-h" or "--help" if they want to find out what all the  parameters are of your
application.  Currently if I just enter the "-h" I get an ParseException exception because
all the required options have not been entered.  

(This is an answer to this question that appeared on/around May 9th.,
not from me.)


What you can do is use OptionGroups and make one of either group
(one group contains -h the other the normal usage)

In the latest version this functionality results in invalid automated
formatter output. I understand a new version may well be on it's way
does some major rejiggin and fixes this.

If you don't care about the auto help then the groups should work fine

Matt Hope

-----Original Message-----
From: Sigler, John [] 
Sent: 08 May 2003 19:18
Subject: [CLI] required options vs. usage

I'd like to set some options as required command line arguments, which
required _except_ when someone wants to see the usage text. That is, the


throws a missing argument exception (and probably prints usage) because
there were missing required switches of "-s -f filename" switch. And:

  foo -s -f file -o -g -l

works because -s and -f file match the required options (and the others
weren't). And:

  foo -h

prints usage and exits and ignores the required arguments.

I'd think this is fairly common but the only way I see to do this is not
required options and handle that logic myself. Am I missing something


View raw message