Skip to content

Commit

Permalink
Merge branch 'master' of github.com:cbeust/jcommander
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeust committed Jun 11, 2012
2 parents e903207 + 074b8af commit 0975e46
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -2,6 +2,7 @@ Current


Added: IValueValidator to validate parameter values (typed) as oppoed to IParameterValidator which validates strings 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) 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: 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: 113: getCommandDescription() returns the description of the main parameter instead of that of the command
Fixed: bug with several multiple arity parameters (VariableArityTest) Fixed: bug with several multiple arity parameters (VariableArityTest)
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/com/beust/jcommander/JCommander.java
Expand Up @@ -492,11 +492,8 @@ private static List<String> readFile(String fileName) {
*/ */
private static String trim(String string) { private static String trim(String string) {
String result = string.trim(); String result = string.trim();
if (result.startsWith("\"")) { if (result.startsWith("\"") && result.endsWith("\"")) {
if (result.endsWith("\"")) { result = result.substring(1, result.length() - 1);
return result.substring(1, result.length() - 1);
}
return result.substring(1);
} }
return result; return result;
} }
Expand Down
9 changes: 4 additions & 5 deletions src/test/java/com/beust/jcommander/JCommanderTest.java
Expand Up @@ -762,15 +762,14 @@ class SlashSeparator {
public void equalSeparator() { public void equalSeparator() {
@Parameters(separators = "=", commandDescription = "My command") @Parameters(separators = "=", commandDescription = "My command")
class MyClass { class MyClass {
@Parameter(names = { "-p", "--param" }, required = true,
description = "param desc...") @Parameter(names = { "-p", "--param" }, required = true, description = "param desc...")
private String param; private String param;
} }

MyClass c = new MyClass(); MyClass c = new MyClass();
String expected = "some=value"; String expected = "\"hello\"world";
new JCommander(c).parse("--param=" + expected); new JCommander(c).parse("--param=" + expected);
Assert.assertEquals(c.param, expected); Assert.assertEquals(expected, c.param);
} }


@Test(enabled = false) @Test(enabled = false)
Expand Down

0 comments on commit 0975e46

Please sign in to comment.