summaryrefslogtreecommitdiffstats
path: root/README.markdown
blob: ade1ab9083aeb286a60b0fbda7a00191349a7bf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
JCommander
==========

This is an annotation based parameter parsing framework for Java.

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;
    }

and how you use it:

    JCommanderTest jct = new JCommanderTest();
    String[] argv = { "-log", "2", "-groups", "unit", "a", "b", "c" };
    new JCommander(jct, argv);

    Assert.assertEquals(jct.verbose.intValue(), 2);

The full doc is available at http://beust.com/jcommander