8

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.

guido
  • 18,864
  • 6
  • 70
  • 95
user2281439
  • 673
  • 2
  • 11
  • 19

1 Answers1

15

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 ...
donnyton
  • 5,874
  • 9
  • 42
  • 60