blob: ade1ab9083aeb286a60b0fbda7a00191349a7bf1 [file] [log] [blame]
Cedric Beust2cc20eb2010-07-12 22:45:52 -07001JCommander
2==========
3
4This is an annotation based parameter parsing framework for Java.
5
Cedric Beust01b687e2010-07-12 22:52:28 -07006Here is a quick example:
7
8 public class JCommanderTest {
9 @Parameter
10 public List<String> parameters = Lists.newArrayList();
11
12 @Parameter(names = { "-log", "-verbose" }, description = "Level of verbosity")
13 public Integer verbose = 1;
14
15 @Parameter(names = "-groups", description = "Comma-separated list of group names to be run")
16 public String groups;
17
18 @Parameter(names = "-debug", description = "Debug mode")
19 public boolean debug = false;
20 }
21
22and how you use it:
23
24 JCommanderTest jct = new JCommanderTest();
25 String[] argv = { "-log", "2", "-groups", "unit", "a", "b", "c" };
26 new JCommander(jct, argv);
27
28 Assert.assertEquals(jct.verbose.intValue(), 2);
Cedric Beust01b687e2010-07-12 22:52:28 -070029
Cedric Beustbb96cc82010-07-13 07:12:41 -070030The full doc is available at http://beust.com/jcommander