java/copy-image-resizer/src/cz/frantovo/copyImageResizer/cli/CLIParser.java
changeset 5 5019e3e93a4e
parent 4 f3b4caf1d05d
child 7 8e9983260624
     1.1 --- a/java/copy-image-resizer/src/cz/frantovo/copyImageResizer/cli/CLIParser.java	Sun Nov 16 21:59:13 2014 +0100
     1.2 +++ b/java/copy-image-resizer/src/cz/frantovo/copyImageResizer/cli/CLIParser.java	Sun Nov 16 23:47:28 2014 +0100
     1.3 @@ -17,6 +17,7 @@
     1.4   */
     1.5  package cz.frantovo.copyImageResizer.cli;
     1.6  
     1.7 +import cz.frantovo.copyImageResizer.RecursiveOptions;
     1.8  import java.io.File;
     1.9  import java.util.Arrays;
    1.10  import java.util.Collection;
    1.11 @@ -27,8 +28,8 @@
    1.12   */
    1.13  public class CLIParser {
    1.14  
    1.15 -	public CLIOptions parseOptions(String[] args) throws CLIParserException {
    1.16 -		CLIOptions options = new CLIOptions();
    1.17 +	public RecursiveOptions parseOptions(String[] args) throws CLIParserException {
    1.18 +		RecursiveOptions options = new RecursiveOptions();
    1.19  
    1.20  		for (int i = 0; i < args.length; i++) {
    1.21  			String arg = args[i];
    1.22 @@ -63,7 +64,7 @@
    1.23  
    1.24  		INPUT_DIR("--input-dir") { // bash-completion: option
    1.25  					@Override
    1.26 -					public int parse(String[] args, int index, CLIOptions options) throws CLIParserException {
    1.27 +					public int parse(String[] args, int index, RecursiveOptions options) throws CLIParserException {
    1.28  						int originalIndex = index;
    1.29  						String name = fetchNext(args, ++index);
    1.30  						options.setInput(new File(name));
    1.31 @@ -72,7 +73,7 @@
    1.32  				},
    1.33  		OUTPUT_DIR("--output-dir") { // bash-completion: option
    1.34  					@Override
    1.35 -					public int parse(String[] args, int index, CLIOptions options) throws CLIParserException {
    1.36 +					public int parse(String[] args, int index, RecursiveOptions options) throws CLIParserException {
    1.37  						int originalIndex = index;
    1.38  						String name = fetchNext(args, ++index);
    1.39  						options.setOutput(new File(name));
    1.40 @@ -81,23 +82,23 @@
    1.41  				},
    1.42  		SIZE("--size") { // bash-completion: option
    1.43  					@Override
    1.44 -					public int parse(String[] args, int index, CLIOptions options) throws CLIParserException {
    1.45 +					public int parse(String[] args, int index, RecursiveOptions options) throws CLIParserException {
    1.46  						int originalIndex = index;
    1.47  						int width = parseInt(fetchNext(args, ++index));
    1.48  						int height = parseInt(fetchNext(args, ++index));
    1.49  						String directory = width + "x" + height;
    1.50 -						options.addSize(new CLIOptions.SizeSpecification(width, height, directory));
    1.51 +						options.addSize(new RecursiveOptions.SizeSpecification(width, height, directory));
    1.52  						return index - originalIndex;
    1.53  					}
    1.54  				},
    1.55  		SIZE_NAMED("--size-named") { // bash-completion: option
    1.56  					@Override
    1.57 -					public int parse(String[] args, int index, CLIOptions options) throws CLIParserException {
    1.58 +					public int parse(String[] args, int index, RecursiveOptions options) throws CLIParserException {
    1.59  						int originalIndex = index;
    1.60  						int width = parseInt(fetchNext(args, ++index));
    1.61  						int height = parseInt(fetchNext(args, ++index));
    1.62  						String directory = fetchNext(args, ++index);
    1.63 -						options.addSize(new CLIOptions.SizeSpecification(width, height, directory));
    1.64 +						options.addSize(new RecursiveOptions.SizeSpecification(width, height, directory));
    1.65  						return index - originalIndex;
    1.66  					}
    1.67  				};
    1.68 @@ -134,6 +135,6 @@
    1.69  		 * return 0, otherwise return positive integer: number of eaten arguments.
    1.70  		 * @throws CLIParserException
    1.71  		 */
    1.72 -		public abstract int parse(String[] args, int index, CLIOptions options) throws CLIParserException;
    1.73 +		public abstract int parse(String[] args, int index, RecursiveOptions options) throws CLIParserException;
    1.74  	}
    1.75  }