I'm struggling on how to use the withValueSeparator() option;

Taking the following piece of code ...

Options options = new Options();
Option columns = OptionBuilder
                            .hasArg()
                            .withArgName("CSV columns")
                            .withValueSeparator(',')
                            .withDescription("Specify the comma separated
list of columns")
                            .create("columns");
options.addOption(columns);

CommandLineParser parser = new GnuParser();
CommandLine line = parser.parse(options, new String[]{ "-columns",
"a,b,c"});
System.out.println("hasOption:" + line.hasOption("columns"));
System.out.println("column count:" +
line.getOptionValues("columns").length);

I woudl expect it to print out something like:
hasOption:true
column count:3

whereas in fact I'm getting
hasOption:true
column count:1

i.e. despite me specifying ',' as a value separator, getOptionValues() is
returning a array that is one element in size, containing "a,b,c" instead
of three elements, each containing a single letter.

I'm missing something - what it is?

Thanks,

Greg

Reply via email to