Multiple args with arg4j

args4j, java

Solution

Try:

import org.kohsuke.args4j.spi.StringArrayOptionHandler;

@Option(name = "-p", handler = StringArrayOptionHandler.class, required = true)
private List<String> list;

which should allow

-p arg1 arg2 ...

Problem

I have a parameter which I need to parse from command line. I use for this arg4j of version 2.0.23. I need to parse path parameter and in command line can be specified one or more path's. So I need to parse multiple params. Here's the way I find: ``` private List<String> list = new ArrayList<String>(); @Option(name = "-p", required = true) public void addPath(String arg) {list.add(arg);} ``` It works ok. But I want to know is it correct or there is a better way? I've googled that in version 2.0.13 there was parameter multipleValue in @Option, but seems now it's gone.

Original source