1.1 --- a/java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIParser.java Thu Jul 03 00:18:35 2014 +0200
1.2 +++ b/java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIParser.java Thu Jul 03 00:37:38 2014 +0200
1.3 @@ -18,7 +18,6 @@
1.4 package cz.frantovo.alt2xml.cli;
1.5
1.6 import java.io.File;
1.7 -import java.io.InputStream;
1.8
1.9 /**
1.10 * Converts command line arguments from String array to object.
1.11 @@ -29,22 +28,28 @@
1.12 */
1.13 public class CLIParser {
1.14
1.15 - public CLIOptions parseOptions(String[] args, InputStream in) throws CLIParserException {
1.16 + public CLIOptions parseOptions(String[] args) throws CLIParserException {
1.17 CLIOptions options = new CLIOptions();
1.18
1.19 for (int i = 0; i < args.length; i++) {
1.20 String arg = args[i];
1.21
1.22 + boolean matches = false;
1.23 +
1.24 for (Token t : Token.values()) {
1.25 if (t.matches(arg)) {
1.26 - t.parse(args, i, options);
1.27 + int parsedArgs = t.parse(args, i, options);
1.28 + i = i + parsedArgs;
1.29 + matches = true;
1.30 }
1.31 }
1.32
1.33 - throw new CLIParserException("Unknown option: " + arg);
1.34 + if (!matches) {
1.35 + throw new CLIParserException("Unknown option: " + arg);
1.36 + }
1.37 }
1.38
1.39 - // Default output: STDOUT
1.40 + // Default output:
1.41 options.setOutputStream(System.out);
1.42
1.43 return options;
1.44 @@ -75,14 +80,6 @@
1.45 return 0;
1.46 }
1.47 },
1.48 - INPUT_URL("--input-url") {
1.49 - @Override
1.50 - public int parse(String[] args, int index, CLIOptions options) throws CLIParserException {
1.51 - int originalIndex = index;
1.52 - options.setInputUrl(fetchNext(args, ++index));
1.53 - return index - originalIndex;
1.54 - }
1.55 - },
1.56 SYSTEM_ID("--system-id") {
1.57 @Override
1.58 public int parse(String[] args, int index, CLIOptions options) throws CLIParserException {