summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric Beust <cedric@beust.com>2012-10-25 09:05:19 -0700
committerCedric Beust <cedric@beust.com>2012-10-25 09:05:19 -0700
commit6575612c8e96ca37744a324d7d5e9c8c9ec7e95f (patch)
tree1887cebc2a3ad2e7cb626acb8152255bc5e5e1d8
parent30931bb8f8b8edfad31160e13230e8bc6f85e72b (diff)
parentf50612c269bd81a78f1b215357075f14f77a5970 (diff)
downloadplatform_external_jcommander-6575612c8e96ca37744a324d7d5e9c8c9ec7e95f.tar.gz
platform_external_jcommander-6575612c8e96ca37744a324d7d5e9c8c9ec7e95f.tar.bz2
platform_external_jcommander-6575612c8e96ca37744a324d7d5e9c8c9ec7e95f.zip
Merge pull request #139 from Vanuan/master
Provide more detailed example
-rw-r--r--README.markdown15
1 files changed, 12 insertions, 3 deletions
diff --git a/README.markdown b/README.markdown
index bf479db..0aecbf5 100644
--- a/README.markdown
+++ b/README.markdown
@@ -18,17 +18,26 @@ public class JCommanderTest {
@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:
```java
-CommanderTest jct = new JCommanderTest();
-String[] argv = { "-log", "2", "-groups", "unit", "a", "b", "c" };
+JCommanderTest jct = new JCommanderTest();
+String[] argv = { "-log", "2", "-groups", "unit1,unit2,unit3",
+ "-debug", "-Doption=value", "a", "b", "c" };
new JCommander(jct, argv);
-Assert.assertEquals(jct.verbose.intValue(), 2);
+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://beust.com/jcommander