commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <d...@solaraccess.com>
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
required
(one group contains -h the other the normal usage)

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

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

Matt Hope

-----Original Message-----
From: Sigler, John [mailto:John.Sigler@sabre.com] 
Sent: 08 May 2003 19:18
To: commons-user@jakarta.apache.org
Subject: [CLI] required options vs. usage


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

  foo

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
use
required options and handle that logic myself. Am I missing something
obvious?

john



Mime
View raw message