You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by John Keyes <jb...@mac.com> on 2003/06/11 01:27:43 UTC
Re: [CLI][PATCH] Min and Max size for arguments
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
Re: [CLI][PATCH] Min and Max size for arguments
Posted by Rob Oxspring <ro...@imapmail.org>.
----- Original Message -----
From: "John Keyes" <jb...@mac.com>
To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
Sent: Wednesday, June 11, 2003 12:27 AM
Subject: Re: [CLI][PATCH] Min and Max size for arguments
> > 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.
Sound good.
>
> > 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.
Hmm, there's room for confusion here. My implementation of hasOptionalValues() says "are any values optional" whereas yours says
"are all values optional". I suspect that we should just drop the method and get people to ask the question they mean to by using
getMin/Max.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org