• Stars
    star
    1,925
  • Rank 24,079 (Top 0.5 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 14 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Command line parsing framework for Java

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" };
JCommander.newBuilder()
  .addObject(jct)
  .build()
  .parse(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 https://jcommander.org.

Building JCommander

./gradlew assemble

More Repositories

1

klaxon

A JSON parser for Kotlin
Kotlin
1,846
star
2

kobalt

A Kotlin-based build system for the JVM.
Kotlin
432
star
3

kash

A shell powered by Kotlin
Kotlin
295
star
4

chip-8

A Chip-8 emulator written in Kotlin
Kotlin
90
star
5

kotlin-android-example

Kotlin
54
star
6

kobalt-android

Android plug-in for Kobalt
Kotlin
33
star
7

space-invade.rs

An 8080 Space Invaders emulator in Rust
Rust
30
star
8

kobalt-intellij-plugin

An IntelliJ plug-in for Kobalt
Kotlin
21
star
9

nnk

Neural Network for Kotlin
Kotlin
20
star
10

koolaid

Simple Kotlin + DropWizard + Heroku cloud demo
Kotlin
16
star
11

sixty

Cédric's Apple ][ emulator.
Kotlin
8
star
12

konfig

A statically typed configuration library for Kotlin
Kotlin
5
star
13

kobalt-examples

Various examples built with Kobalt
Java
5
star
14

guess-card

HTML
4
star
15

jbus

A simple local software bus
Java
4
star
16

kash-example

Examples of static extensions to the Kash shell
Kotlin
4
star
17

banker-amiga

The source of an application I wrote for the Amiga in 1994
C
4
star
18

translate

Translate application for Android
Java
3
star
19

sixty.rs

A 6502 emulator in Rust
Rust
3
star
20

stormlin

A simple ORM for Kotlin
Kotlin
2
star
21

testng-prod

Production site for http://testng.org
JavaScript
2
star
22

inliner

A tool that converts a file into a Rust array.
Rust
2
star
23

beust-com

http://beust.com backup
HTML
2
star
24

version-processor

A simple apt example built with Kobalt
Java
2
star
25

kobalt-retrolambda

A Retrolambda plug-in for Kobalt
Kotlin
2
star
26

perry-php

perry-php
PHP
1
star
27

cedCube

Rubik's Cube in Javascript
JavaScript
1
star
28

misc

Miscellanous stuff
JavaScript
1
star
29

perry

Source of the software that runs http://beust.com/perry
HTML
1
star
30

dropwizard-guice

Sample application for DropWizard and Guice
Java
1
star
31

cubejs

JavaScript
1
star
32

perry-rhodan-java

Clean up strings in Perry Rhodan books
Java
1
star
33

cbdemo

Kotlin
1
star
34

house.js

1
star
35

testng-maven-plugin

TestNG Maven plug-on
Java
1
star
36

ktracer

A ray tracer written in Kotlin
Kotlin
1
star
37

ultimate-craft-queue

Ultimate Craft Queue is a World of Warcraft add-on to handle glyph crafting
Lua
1
star