cli: support --input-url and multiple names per option (might be used for short variants like -i, -a etc.)
authorFrantišek Kučera <franta-hg@frantovo.cz>
Thu, 04 Sep 2014 16:28:49 +0200
changeset 6796ce967c0182
parent 66 9837e58e0754
child 68 b814f45b6beb
cli: support --input-url and multiple names per option (might be used for short variants like -i, -a etc.)
java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIParser.java
     1.1 --- a/java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIParser.java	Thu Sep 04 16:18:59 2014 +0200
     1.2 +++ b/java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIParser.java	Thu Sep 04 16:28:49 2014 +0200
     1.3 @@ -18,6 +18,8 @@
     1.4  package cz.frantovo.alt2xml.cli;
     1.5  
     1.6  import java.io.File;
     1.7 +import java.util.Arrays;
     1.8 +import java.util.Collection;
     1.9  
    1.10  /**
    1.11   * Converts command line arguments from String array to object.
    1.12 @@ -80,7 +82,7 @@
    1.13  						return 0;
    1.14  					}
    1.15  				},
    1.16 -		SYSTEM_ID("--system-id") {
    1.17 +		SYSTEM_ID("--system-id", "--input-url") {
    1.18  					@Override
    1.19  					public int parse(String[] args, int index, CLIOptions options) throws CLIParserException {
    1.20  						int originalIndex = index;
    1.21 @@ -127,10 +129,10 @@
    1.22  					}
    1.23  				};
    1.24  
    1.25 -		private final String option;
    1.26 +		private final Collection<String> options;
    1.27  
    1.28 -		private Token(String option) {
    1.29 -			this.option = option;
    1.30 +		private Token(String... options) {
    1.31 +			this.options = Arrays.asList(options);
    1.32  		}
    1.33  
    1.34  		/**
    1.35 @@ -138,7 +140,7 @@
    1.36  		 * @return whether option is this token
    1.37  		 */
    1.38  		public boolean matches(String option) {
    1.39 -			return this.option.equals(option);
    1.40 +			return options.contains(option);
    1.41  		}
    1.42  
    1.43  		/**