Repository: joelittlejohn/jsonschema2pojo (java)

Issue:
Fix questionable error message for the application of a source file name filter
I am trying the current software release out.

```
Markus_Elfring@…:~/Downloads/Freeware/jsonschema2pojo-1.1.2/bin> sh jsonschema2pojo -s ~/Test/JSON/Schemas/*Schema1.json -t ~/Bau/JSON/Schemas
Was passed main parameter '/home/Markus_Elfring/Test/JSON/Schemas/Staffelstufe-reduced-Schema1.json' but no main parameter was defined
Usage: jsonschema2pojo [options]
…
  * -s, --source
       The source file(s) or directory(ies) from which JSON Schema will be read
…
```

How does the shown error message fit to the applied source file name filter according to the presented help information? :thinking:

:crystal_ball: Can affected implementation details be improved further?

Pull request:
Accept multiple values provided with single "-s"/"--source" argument
Closes #1422

Patch:
diff --git a/jsonschema2pojo-cli/src/main/java/org/jsonschema2pojo/cli/Arguments.java b/jsonschema2pojo-cli/src/main/java/org/jsonschema2pojo/cli/Arguments.java
index 893efa61..88ab72ec 100644
--- a/jsonschema2pojo-cli/src/main/java/org/jsonschema2pojo/cli/Arguments.java
+++ b/jsonschema2pojo-cli/src/main/java/org/jsonschema2pojo/cli/Arguments.java
@@ -59,7 +59,7 @@ public class Arguments implements GenerationConfig {
     @Parameter(names = { "-t", "--target" }, description = "The target directory into which generated types will be written", required = true)
     private File targetDirectory;
 
-    @Parameter(names = { "-s", "--source" }, description = "The source file(s) or directory(ies) from which JSON Schema will be read", required = true, converter = UrlConverter.class)
+    @Parameter(names = { "-s", "--source" }, description = "The source file(s) or directory(ies) from which JSON Schema will be read", required = true, variableArity = true, converter = UrlConverter.class)
     private List<URL> sourcePaths;
 
     @Parameter(names = { "-b", "--generate-builders" }, description = "Generate builder-style methods as well as setters")


Test patch:
diff --git a/jsonschema2pojo-cli/src/test/java/org/jsonschema2pojo/cli/ArgumentsTest.java b/jsonschema2pojo-cli/src/test/java/org/jsonschema2pojo/cli/ArgumentsTest.java
index 8e88565b..477fb3e1 100644
--- a/jsonschema2pojo-cli/src/test/java/org/jsonschema2pojo/cli/ArgumentsTest.java
+++ b/jsonschema2pojo-cli/src/test/java/org/jsonschema2pojo/cli/ArgumentsTest.java
@@ -22,7 +22,9 @@ import static org.hamcrest.Matchers.*;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.PrintStream;
+import java.net.URL;
 import java.nio.charset.StandardCharsets;
+import java.util.Iterator;
 
 import org.jsonschema2pojo.InclusionLevel;
 import org.junit.After;
@@ -151,6 +153,46 @@ public class ArgumentsTest {
         assertThat(new String(systemOutCapture.toByteArray(), StandardCharsets.UTF_8).matches("(?s)jsonschema2pojo version \\d.*"), is(true));
     }
 
+    @Test
+    public void parseRecognisesSourceWithMultipleValues() {
+        ArgsForTest args = (ArgsForTest) new ArgsForTest().parse(new String[] {
+                "-s", "/home/source", "/home/second_source", "-t", "/home/target"
+        });
+
+        assertThat(args.didExit(), is(false));
+        final Iterator<URL> sources = args.getSource();
+        assertThat(sources.next().getFile(), endsWith("/home/source"));
+        assertThat(sources.next().getFile(), endsWith("/home/second_source"));
+        assertThat(sources.hasNext(), is(false));
+    }
+
+    @Test
+    public void parseRecognisesMultipleSources() {
+        ArgsForTest args = (ArgsForTest) new ArgsForTest().parse(new String[] {
+                "-s", "/home/source", "-s", "/home/second_source", "-t", "/home/target"
+        });
+
+        assertThat(args.didExit(), is(false));
+        final Iterator<URL> sources = args.getSource();
+        assertThat(sources.next().getFile(), endsWith("/home/source"));
+        assertThat(sources.next().getFile(), endsWith("/home/second_source"));
+        assertThat(sources.hasNext(), is(false));
+    }
+
+    @Test
+    public void parseRecognisesMultipleSourcesWithMultipleValues() {
+        ArgsForTest args = (ArgsForTest) new ArgsForTest().parse(new String[] {
+                "-s", "/home/source", "/home/second_source", "-s", "/home/third_source", "-t", "/home/target"
+        });
+
+        assertThat(args.didExit(), is(false));
+        final Iterator<URL> sources = args.getSource();
+        assertThat(sources.next().getFile(), endsWith("/home/source"));
+        assertThat(sources.next().getFile(), endsWith("/home/second_source"));
+        assertThat(sources.next().getFile(), endsWith("/home/third_source"));
+        assertThat(sources.hasNext(), is(false));
+    }
+
     private File theFile(String path) {
         return new File(path);
     }