Permalink
Browse files

Merge branch 'master' of github.com:cbeust/jcommander

  • Loading branch information...
2 parents e903207 + 074b8af commit 0975e46cbf9e8aa7febc03dc38be47c19b408371 @cbeust committed Jun 11, 2012
View
@@ -2,6 +2,7 @@ Current
Added: IValueValidator to validate parameter values (typed) as oppoed to IParameterValidator which validates strings
Added: echoInput, used when password=true to echo the characters (Jason Wheeler)
+Fixed: wasn't handling parameters that start with " but don't end with one correctly
Fixed: if using a different option prefix, unknown option are mistakenly reported as "no main parameter defined" (kurmasz)
Fixed: 113: getCommandDescription() returns the description of the main parameter instead of that of the command
Fixed: bug with several multiple arity parameters (VariableArityTest)
@@ -492,11 +492,8 @@ private String getOptionPrefixes(String[] args, String arg) {
*/
private static String trim(String string) {
String result = string.trim();
- if (result.startsWith("\"")) {
- if (result.endsWith("\"")) {
- return result.substring(1, result.length() - 1);
- }
- return result.substring(1);
+ if (result.startsWith("\"") && result.endsWith("\"")) {
+ result = result.substring(1, result.length() - 1);
}
return result;
}
@@ -762,15 +762,14 @@ public void unknownOptionWithDifferentPrefix() {
public void equalSeparator() {
@Parameters(separators = "=", commandDescription = "My command")
class MyClass {
- @Parameter(names = { "-p", "--param" }, required = true,
- description = "param desc...")
+
+ @Parameter(names = { "-p", "--param" }, required = true, description = "param desc...")
private String param;
}
-
MyClass c = new MyClass();
- String expected = "some=value";
+ String expected = "\"hello\"world";
new JCommander(c).parse("--param=" + expected);
- Assert.assertEquals(c.param, expected);
+ Assert.assertEquals(expected, c.param);
}
@Test(enabled = false)

0 comments on commit 0975e46

Please sign in to comment.