Permalink
Browse files

Fixed: 113: getCommandDescription() returns the description of the ma…

…in parameter instead of that of the command
  • Loading branch information...
cbeust committed May 8, 2012
1 parent 5219e93 commit 13a57cd81965605f1050f20ed2d4169e6d6d24df
View
@@ -1,5 +1,6 @@
Current
+Fixed: 113: getCommandDescription() returns the description of the main parameter instead of that of the command
Fixed: bug with several multiple arity parameters (VariableArityTest)
Fixed: variable arities not working when same parameter appears multiple times.
@@ -901,9 +901,10 @@ public String getCommandDescription(String commandName) {
Object arg = jc.getObjects().get(0);
Parameters p = arg.getClass().getAnnotation(Parameters.class);
- String result = jc.getMainParameterDescription();
ResourceBundle bundle = null;
+ String result = null;
if (p != null) {
+ result = p.commandDescription();
String bundleName = p.resourceBundle();
if (!"".equals(bundleName)) {
bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
@@ -701,21 +701,11 @@ public void multiVariableArityList() {
private List<String> paramB = Lists.newArrayList();
}
- {
- String args[] = { "-paramA", "a1", "a2", "-paramB", "b1", "b2", "b3" };
- Params p = new Params();
- new JCommander(p, args).parse();
- Assert.assertEquals(p.paramA, Arrays.asList(new String[] { "a1", "a2" }));
- Assert.assertEquals(p.paramB, Arrays.asList(new String[] { "b1", "b2", "b3" }));
- }
-
- {
- String args[] = { "-paramA", "a1", "a2", "-paramB", "b1", "-paramA", "a3" };
- Params p = new Params();
- new JCommander(p, args).parse();
- Assert.assertEquals(p.paramA, Arrays.asList(new String[] { "a1", "a2", "a3" }));
- Assert.assertEquals(p.paramB, Arrays.asList(new String[] { "b1" }));
- }
+ String args[] = { "-paramA", "a1", "a2", "-paramB", "b1", "b2", "b3" };
+ Params p = new Params();
+ new JCommander(p, args).parse();
+ Assert.assertEquals(p.paramA, Arrays.asList(new String[] { "a1", "a2" }));
+ Assert.assertEquals(p.paramB, Arrays.asList(new String[] { "b1", "b2", "b3" }));
}
@Test(enabled = false,
@@ -734,7 +724,7 @@ public void commandKey() {
@Test(enabled = false)
public static void main(String[] args) throws Exception {
- new JCommanderTest().multiVariableArityList();
+ new JCommanderTest().commandKey();
// System.out.println("Help:" + a.help);
// System.out.println("A");
// class A {

0 comments on commit 13a57cd

Please sign in to comment.