How to parse commandline parameter that occur multiple times
how to parse commandline parameter for that defintion:
myjar [-hv] [[--exclude PATTERN]...] dir
It should be possible to put multiple --exclude PATTERN and define exactly
one dir.
At the end it should match to this config class:
static class CliConfig {
public boolean verbose;
public List<String> filter;
public String dir;
}
This are some valid examples:
myjar -v --exclude *.jpg --exclude *.jpeg /tmp
myjar /tmp
myjar -h
I had a look to apache-commons-cli, jcommander and args4j but I couldn't
make it running for the --exclude PATTERN. They have this "multi variable"
options just for the last parameter. Or i overread it.
I'm free in choosing any library.
P.S.: This is similar to the linux program: ncdu
No comments:
Post a Comment