diff -r 3d5cc308e268 -r c703fb7f088f java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIParser.java --- a/java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIParser.java Thu Jul 03 00:18:35 2014 +0200 +++ b/java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIParser.java Thu Jul 03 00:37:38 2014 +0200 @@ -18,7 +18,6 @@ package cz.frantovo.alt2xml.cli; import java.io.File; -import java.io.InputStream; /** * Converts command line arguments from String array to object. @@ -29,22 +28,28 @@ */ public class CLIParser { - public CLIOptions parseOptions(String[] args, InputStream in) throws CLIParserException { + public CLIOptions parseOptions(String[] args) throws CLIParserException { CLIOptions options = new CLIOptions(); for (int i = 0; i < args.length; i++) { String arg = args[i]; + boolean matches = false; + for (Token t : Token.values()) { if (t.matches(arg)) { - t.parse(args, i, options); + int parsedArgs = t.parse(args, i, options); + i = i + parsedArgs; + matches = true; } } - throw new CLIParserException("Unknown option: " + arg); + if (!matches) { + throw new CLIParserException("Unknown option: " + arg); + } } - // Default output: STDOUT + // Default output: options.setOutputStream(System.out); return options; @@ -75,14 +80,6 @@ return 0; } }, - INPUT_URL("--input-url") { - @Override - public int parse(String[] args, int index, CLIOptions options) throws CLIParserException { - int originalIndex = index; - options.setInputUrl(fetchNext(args, ++index)); - return index - originalIndex; - } - }, SYSTEM_ID("--system-id") { @Override public int parse(String[] args, int index, CLIOptions options) throws CLIParserException {