commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Keyes <j...@mac.com>
Subject Re: [CLI][PATCH] Min and Max size for arguments
Date Tue, 10 Jun 2003 23:27:43 GMT

On Tuesday, Jun 10, 2003, at 18:40 Europe/Dublin, Rob Oxspring wrote:

> Attached is a patch that allows arguments to have specified a minimum  
> and maximum number of values rather than just the previous
> "size".  An example of use might be where you are selecting a number  
> of files for an operation but want to ensure that at least one
> value was specified:
>
>         options.add(
>             ArgumentBuilder
>                 .createBuilder()
>                 .withLongName("search-location")
>                 .withMinimumSize(1)
>                 .withMaximumSize(100)
>                 .withValueName("directory")
>                 .create());
>
> ArgumentBuilder.withSize(int) has been retained and sets both min and  
> max to the same.  (This might be a bad thing if both size and
> min/max are specified though).
I think that we can remove withSize, if someone calls withMaximumSize  
then the
minSize should be set to 1 automatically.  It should be explicit for  
someone to
specify a minimum size of 0 i.e. an optional value.

> ArgumentBuilder.withOptionalValues(boolean) has been removed since its  
> a function of the min and max values.
>
> Argument.hasOptionalValues() has been retained and returns min<max
This should just return min == 0?  If min is > 0 then that means a  
value is
required.

> Argument.getSize() has been removed and getMaximumSize() or  
> getMinimumSize() should be used instead.
>
> Thoughts welcome.  If you want me to commit it myself then I'll need  
> access to jakarta-commons first.
Thats brilliant.  Thanks Rob.  I'll look through the patch and make the  
changes
I specified here.  I'll get it commited tomorrow at some stage.  I'll  
also stick
the license on the testcase, no probs.

Thanks again,
-John K

>
> Rob
>
> Oh - and the extra testcase needs the apache licence attached, whoops.
> <ArgumentMinAndMaxSize.zip>-------------------------------------------- 
> -------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
- - - - - - - - - - - - - - - - - - - - - - -
Jakarta Commons CLI
http://jakarta.apache.org/commons/cli


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


Mime
View raw message