Skip to content

Commit

Permalink
[#1383][#1502] cosmetic changes; update RELEASE-NOTES.md
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed Dec 8, 2021
1 parent 0dd281f commit ee88bd2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Picocli follows [semantic versioning](http://semver.org/).
* [#1476] Enhancement: improve error message in `AbstractCommandSpecProcessor#extractTypedMember`. Thanks to [Ross Goldberg](https://github.com/rgoldberg) for raising this.
* [#1475] Enhancement: Fix typo in annotation target-type error message. Thanks to [Ross Goldberg](https://github.com/rgoldberg) for the pull request.
* [#1409][#1463] DOC: add documentation section on using default values in argument groups. Thanks to [Ben Kedo](https://github.com/MadFoal) for the pull request.
* [#1383][#1502] DOC: add tests demonstrating usage of multiple arguments. Thanks to [Ben Kedo](https://github.com/MadFoal) and [lind6](https://github.com/lind6) for the pull request.
* [#1462] DOC, BUILD, DEP: Extend documentation on argument files, fix broken/outdated links, update dependencies. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
* [#1457] DOC: add caution about arguments in @files with quoted option parameters. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
* [#1461] BUILD: Allow publishing without signing for non-release versions. Thanks to [Andreas Deininger](https://github.com/deining) for raising this.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import org.junit.Test;
import picocli.CommandLine.Command;
import picocli.CommandLine.PicocliException;

import java.util.Locale;
import static org.junit.Assert.assertEquals;

import static org.junit.Assert.*;

/**
* Multiple Arguments Testing based on https://picocli.info/#_multiple_values
Expand All @@ -14,14 +17,15 @@
* multiple argument with split, flags, and type conversion
* @author @madfoal, @lind6
*/
public class MultipleArgumentsTest {
public class Issue1383MultipleArgumentsTest {

/** default */static final String FLAG_STRING = "-t"; // String literal for the argument flag
/** default */static final String GOOD_STRING = "good test"; // String literal for the good test
/** default */static final String BAD_STRING = "Bad Test"; // String literal for the bad test
/** default */static final String errorMessage = "Invalid value for option '-t' (<args>): "
static final String FLAG_STRING = "-t"; // String literal for the argument flag
static final String GOOD_STRING = "good test"; // String literal for the good test
static final String BAD_STRING = "Bad Test"; // String literal for the bad test
static final String ERROR_MESSAGE = "Invalid value for option '-t' (<args>): "
+"Type Conversion Failure\n" +
"Argument: \"Bad Test\" must be lower case.\n";

@Command(name = "Issue-1383")
/**
* Tests issue 1383 https://github.com/remkop/picocli/issues/1383
Expand All @@ -32,11 +36,11 @@ public class MultipleArgumentsTest {
* @author @madfoal, @lind6
*/
static class Issue1383{
@CommandLine.Option(names = FLAG_STRING,split=",", converter = TestType.TestConverter.class)
@CommandLine.Option(names = FLAG_STRING, split=",", converter = TestType.TestConverter.class)
TestType[] args;

static class TestType {
String str; // only data field for this test type
final String str; // only data field for this test type

private TestType(final String txt) {
str = txt;
Expand All @@ -49,9 +53,9 @@ private TestType(final String txt) {
public static class TestConverter implements
CommandLine.ITypeConverter<Issue1383.TestType> {

@Override
//@Override
public Issue1383.TestType convert(final String arg) throws Exception {
if (!arg.toLowerCase(Locale.ROOT).equals(arg)) {
if (!arg.toLowerCase(Locale.ENGLISH).equals(arg)) {
throw new CommandLine.TypeConversionException(
"Type Conversion Failure\nArgument: \""
+ arg + "\" must be lower case.\n");
Expand All @@ -77,8 +81,8 @@ public void testOneIssue1383RepeatedOptions() {
final Issue1383 obj = new Issue1383();
try {
new CommandLine(obj).parseArgs(args);
} catch ( CommandLine.PicocliException e) {
assertEquals("Multiple Arguments with Type Converter Failure",errorMessage,e.getMessage());
} catch (PicocliException e) {
assertEquals("Multiple Arguments with Type Converter Failure", ERROR_MESSAGE, e.getMessage());
}
}

Expand All @@ -96,8 +100,8 @@ public void testOneIssue1383SplitRegex() {
final Issue1383 obj = new Issue1383();
try {
new CommandLine(obj).parseArgs(args);
} catch ( CommandLine.PicocliException e) {
assertEquals("Multiple Arguments with Type Converter Failure",errorMessage,e.getMessage());
} catch (PicocliException e) {
assertEquals("Multiple Arguments with Type Converter Failure", ERROR_MESSAGE, e.getMessage());
}
}
}

0 comments on commit ee88bd2

Please sign in to comment.