Skip to content

Commit

Permalink
Update readme to add syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
joelittlejohn committed Jul 13, 2012
1 parent 75d579a commit 8767867
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions README.markdown
Expand Up @@ -5,26 +5,30 @@ 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;
}
```java
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);
```java
CommanderTest jct = new JCommanderTest();
String[] argv = { "-log", "2", "-groups", "unit", "a", "b", "c" };
new JCommander(jct, argv);

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

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

0 comments on commit 8767867

Please sign in to comment.