commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Neidhart <thomas.neidh...@gmail.com>
Subject Re: [CLI] - withValueSeparator() usage
Date Wed, 06 Feb 2013 09:55:20 GMT
On 02/05/2013 11:55 AM, Gilles wrote:
> On Tue, 5 Feb 2013 11:33:45 +0100, Thomas Neidhart wrote:
>> On Tue, Feb 5, 2013 at 10:27 AM, Greg Thomas
>> <greg.d.thomas@gmail.com>wrote:
>>
>>> >  If you would specify hasArgs(3), you would indeed get the values
>>> > split into an array of 3 strings.
>>>
>>> Though in my usage, the argument was a CSV list of arbitrary length,
>>> the example I gave just happened to be three.
>>>
>>
>> Well, I do not think this parameter was intended for dynamic sized
>> arguments, but rather for fixed-size key/value pairs.
>> The documentation clearly lacks in explaining what this parameter does,
>> your use-case would be an extension imho (e.g. allow unlimited arg
>> values).
>>
> 
> https://issues.apache.org/jira/browse/CLI-219

Looking at another issue, this seems to be already working, see the
excerpt from a unit test:

options.addOption(OptionBuilder.withValueSeparator(':').hasArgs().create('p'));
String[] args = new String[]
      {"-DJAVA_HOME=/opt/java","-pfile1:file2:file3" };

String[] values = cmd.getOptionValues('p');

values is then an array with 3 elements.

So instead of hasArg(), if you call hasArgs() the number of expected
arguments is unlimited.

Thomas

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


Mime
View raw message