Command line parsing framework for Java
Java Other
Latest commit 1818f40 Oct 8, 2016 @cbeust committed on GitHub Merge pull request #302 from kovalskyi/code-tidy-up
Code tidy up
Permalink
Failed to load latest commit information.
doc Allow to specify the @file charset Sep 12, 2016
gradle Gradle 2.3. Jul 9, 2015
kobalt Bump Kobalt. Sep 29, 2016
src Remove commented-out code Oct 8, 2016
.gitignore .gitignore. Feb 28, 2016
.travis.yml JDK 8 Jun 22, 2016
CHANGELOG.md Rephrases change log. Oct 5, 2016
README.markdown Since 1.58 Java 8 is required Oct 5, 2016
build.gradle Update Gradle Oct 4, 2016
gradlew +x flag for gradlew May 2, 2015
kobaltw Update Kobalt Sep 26, 2016
license.txt Updated license Jan 13, 2012
misc.xml IDEA file. Sep 26, 2016
notice.md Updated the pom Aug 6, 2010
release Changed profile name to 'sign' Sep 6, 2010
upload 1.27 Jul 5, 2012

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