aosp12/external/jcommander
hcl 7be3fd486c init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
..
doc init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
gradle init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
kobalt init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
src init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
.gitignore init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
.travis.yml init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
Android.bp init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
CHANGELOG.md init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
LICENSE init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
METADATA init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
MODULE_LICENSE_APACHE2 init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
OWNERS init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
README.markdown init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
build.gradle init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
gradlew init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
kobaltw init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
license.txt init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
misc.xml init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
notice.md init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
release init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00
upload init from android-12.1.0_r8 2023-01-09 17:11:35 +08:00

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