You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jianglk.darker
7ee447c011
|
4 months ago | |
---|---|---|
.. | ||
doc | 4 months ago | |
gradle | 4 months ago | |
kobalt | 4 months ago | |
lib | 4 months ago | |
src | 4 months ago | |
.travis.yml | 4 months ago | |
Android.bp | 4 months ago | |
CHANGELOG.md | 4 months ago | |
LICENSE | 4 months ago | |
METADATA | 4 months ago | |
MODULE_LICENSE_APACHE2 | 4 months ago | |
OWNERS | 4 months ago | |
README.markdown | 4 months ago | |
build.gradle | 4 months ago | |
gradlew | 4 months ago | |
kobaltw | 4 months ago | |
license.txt | 4 months ago | |
misc.xml | 4 months ago | |
notice.md | 4 months ago | |
release | 4 months ago | |
upload | 4 months ago |
README.markdown
JCommander
This is an annotation based parameter parsing framework for Java 8.
Here is a quick example:
public class JCommanderTest {
@Parameter
public List<String> parameters = Lists.newArrayList();
@Parameter(names = { "-log", "-verbose" }, description = "Level of verbosity")
public Integer verbose = 1;
@Parameter(names = "-groups", description = "Comma-separated list of group names to be run")
public String groups;
@Parameter(names = "-debug", description = "Debug mode")
public boolean debug = false;
@DynamicParameter(names = "-D", description = "Dynamic parameters go here")
public Map<String, String> dynamicParams = new HashMap<String, String>();
}
and how you use it:
JCommanderTest jct = new JCommanderTest();
String[] argv = { "-log", "2", "-groups", "unit1,unit2,unit3",
"-debug", "-Doption=value", "a", "b", "c" };
new JCommander(jct, argv);
Assert.assertEquals(2, jct.verbose.intValue());
Assert.assertEquals("unit1,unit2,unit3", jct.groups);
Assert.assertEquals(true, jct.debug);
Assert.assertEquals("value", jct.dynamicParams.get("option"));
Assert.assertEquals(Arrays.asList("a", "b", "c"), jct.parameters);
The full doc is available at http://jcommander.org.
Building JCommander
./kobaltw assemble