commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Bourg <>
Subject Re: [cli] help with required parameter without throwing exception
Date Wed, 23 Feb 2011 20:11:34 GMT
Hi Jordan,

Sorry for the late response. The solution is to put your required 
parameters into a group.

For example:

     OptionGroup group = new OptionGroup();

     Options options = new Options();

In this case one of the 3 parameters 'help', 'version' or 'file' is 
required to validate the command line.

Does it work with your use case?

Emmanuel Bourg

Le 06/01/2011 20:34, Jordan Thompson a écrit :
> Hi there,
> My scenario is this: I have one or more required parameters and also have a
> help and a version parameter (obviously neither of these are required).
> If the user only passes in a -h or -v (the require parameter is missing) the
> parser will throw a ParseException and the CommandLine will be null.  I want
> to be able differentiate between a user passing a -h or -v.
> Is there a solution to this?
> thanks,
> Jordan
> Jordan R. Thompson

View raw message