From: Svjatoslav Agejenko Date: Sat, 23 Aug 2014 21:03:09 +0000 (+0300) Subject: added possibility to use multiple patterns from command-line X-Git-Tag: meviz-1.0~55 X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=2f596bbc660625e4363be4330a3962227dc8f416;p=meviz.git added possibility to use multiple patterns from command-line --- diff --git a/pom.xml b/pom.xml index 69c73bb..82f8003 100755 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ eu.svjatoslav svjatoslavcommons - 1.3 + 1.4-SNAPSHOT diff --git a/src/main/java/eu/svjatoslav/meviz/bomremove/CommandlineHandler.java b/src/main/java/eu/svjatoslav/meviz/bomremove/CommandlineHandler.java index 16d3e2c..1bc4f3c 100755 --- a/src/main/java/eu/svjatoslav/meviz/bomremove/CommandlineHandler.java +++ b/src/main/java/eu/svjatoslav/meviz/bomremove/CommandlineHandler.java @@ -1,7 +1,7 @@ /* * Meviz - Various tools collection to work with multimedia. * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License * as published by the Free Software Foundation. @@ -14,7 +14,7 @@ import java.io.File; import eu.svjatoslav.commons.commandline.parameterparser.Parser; import eu.svjatoslav.commons.commandline.parameterparser.parameter.DirectoryParameter; import eu.svjatoslav.commons.commandline.parameterparser.parameter.NullParameter; -import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameter; +import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameters; public class CommandlineHandler { @@ -23,7 +23,7 @@ public class CommandlineHandler { NullParameter recursiveParameter = parser.createNullParameter( "Enable recursive mode.").addAliases("-r", "--recursive"); - StringParameter inputPatternParameter = parser.createStringParameter( + StringParameters inputPatternParameter = parser.createStringParameters( "File input pattern.").addAliases("-i", "--input-pattern"); DirectoryParameter workingDirectoryParameter = parser @@ -58,8 +58,7 @@ public class CommandlineHandler { // TODO: add support for multiple input patterns if (inputPatternParameter.isParameterSpecified()) - options.inputPatterns.addAll(inputPatternParameter - .getArgumentsAsStrings()); + options.inputPatterns.addAll(inputPatternParameter.getValue()); return options; } diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/BitrateParameter.java b/src/main/java/eu/svjatoslav/meviz/encoder/BitrateParameter.java index 168f2b4..c8aa863 100755 --- a/src/main/java/eu/svjatoslav/meviz/encoder/BitrateParameter.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/BitrateParameter.java @@ -1,7 +1,7 @@ /* * Meviz - Various tools collection to work with multimedia. * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License * as published by the Free Software Foundation. @@ -14,13 +14,34 @@ import eu.svjatoslav.commons.commandline.parameterparser.Parameter; public class BitrateParameter extends Parameter { - public BitrateParameter(String description) { + static public enum bitrate { + LOW, MEDIUM, HIGH, COPY + } + + public BitrateParameter(final String description) { super(description, ArgumentCount.SINGLE); } + @Override + public BitrateParameter addAliases(final String... aliasArray) { + addAliasesProtected(aliasArray); + return this; + } + @Override public String describeFormat() { return "Target bitrate [LOW / MEDIUM / HIGH / COPY]"; + }; + + @Override + public bitrate getValue() { + return bitrate.valueOf(arguments.get(0).toUpperCase()); + } + + @Override + public BitrateParameter setMandatory() { + setMandatoryProtected(); + return this; } @Override @@ -33,12 +54,4 @@ public class BitrateParameter extends Parameter { return true; } - - static public enum bitrate { - LOW, MEDIUM, HIGH, COPY - }; - - public bitrate getValue() { - return bitrate.valueOf(getArgumentsAsStrings().get(0).toUpperCase()); - } } diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/CommandlineHandler.java b/src/main/java/eu/svjatoslav/meviz/encoder/CommandlineHandler.java index ba54599..102ca7a 100755 --- a/src/main/java/eu/svjatoslav/meviz/encoder/CommandlineHandler.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/CommandlineHandler.java @@ -1,7 +1,7 @@ /* * Meviz - Various tools collection to work with multimedia. * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License * as published by the Free Software Foundation. @@ -12,14 +12,14 @@ package eu.svjatoslav.meviz.encoder; import eu.svjatoslav.commons.commandline.parameterparser.Parser; import eu.svjatoslav.commons.commandline.parameterparser.parameter.DirectoryParameter; import eu.svjatoslav.commons.commandline.parameterparser.parameter.NullParameter; -import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameter; +import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameters; public class CommandlineHandler { Parser parser = new Parser(); - StringParameter outputFormatParameter = parser - .createStringParameter("Encoding output format.") + StringParameters outputFormatParameter = parser + .createStringParameters("Encoding output format.") .addAliases("-o", "--output-format").setMandatory(); NullParameter deinterlaceParameter = parser.createNullParameter( @@ -34,8 +34,8 @@ public class CommandlineHandler { NullParameter forPortableParameter = parser.createNullParameter( "Encode for portable player.").addAliases("-p", "--portable"); - StringParameter inputPatternParameter = parser - .createStringParameter("File input pattern.") + StringParameters inputPatternParameter = parser + .createStringParameters("File input pattern.") .addAliases("-i", "--input-pattern").setMandatory(); DirectoryParameter workingDirectoryParameter = parser @@ -68,16 +68,13 @@ public class CommandlineHandler { options.testOnly = testParameter.isParameterSpecified(); if (outputFormatParameter.isParameterSpecified()) - options.outputFormats.addAll(outputFormatParameter - .getArgumentsAsStrings()); + options.outputFormats.addAll(outputFormatParameter.getValue()); if (workingDirectoryParameter.isParameterSpecified()) - options.workingDirectory = workingDirectoryParameter - .getArgumentsAsFiles().get(0); + options.workingDirectory = workingDirectoryParameter.getValue(); if (inputPatternParameter.isParameterSpecified()) - options.inputPatterns.addAll(inputPatternParameter - .getArgumentsAsStrings()); + options.inputPatterns.addAll(inputPatternParameter.getValue()); options.forPortablePlayer = forPortableParameter.isParameterSpecified(); diff --git a/src/main/java/eu/svjatoslav/meviz/renamer/CommandlineHandler.java b/src/main/java/eu/svjatoslav/meviz/renamer/CommandlineHandler.java index 9eb45de..e5ebda3 100755 --- a/src/main/java/eu/svjatoslav/meviz/renamer/CommandlineHandler.java +++ b/src/main/java/eu/svjatoslav/meviz/renamer/CommandlineHandler.java @@ -1,7 +1,7 @@ /* * Meviz - Various tools collection to work with multimedia. * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License * as published by the Free Software Foundation. @@ -15,6 +15,7 @@ import eu.svjatoslav.commons.commandline.parameterparser.Parser; import eu.svjatoslav.commons.commandline.parameterparser.parameter.DirectoryParameter; import eu.svjatoslav.commons.commandline.parameterparser.parameter.NullParameter; import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameter; +import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameters; import eu.svjatoslav.meviz.encoder.EncodingOptions; public class CommandlineHandler { @@ -31,7 +32,7 @@ public class CommandlineHandler { StringParameter outputPatternParameter = parser.createStringParameter( "Output pattern.").addAliases("-o", "--output-pattern"); - StringParameter inputPatternParameter = parser.createStringParameter( + StringParameters inputPatternParameter = parser.createStringParameters( "File input pattern.").addAliases("-i", "--input-pattern"); DirectoryParameter workingDirectoryParameter = parser @@ -66,8 +67,7 @@ public class CommandlineHandler { // TODO: add multiple input patterns support if (inputPatternParameter.isParameterSpecified()) - options.inputPatterns.addAll(inputPatternParameter - .getArgumentsAsStrings()); + options.inputPatterns.addAll(inputPatternParameter.getValue()); return options; } diff --git a/src/main/java/eu/svjatoslav/meviz/textsplitter/CommandlineHandler.java b/src/main/java/eu/svjatoslav/meviz/textsplitter/CommandlineHandler.java index 8060db6..ef2a27a 100755 --- a/src/main/java/eu/svjatoslav/meviz/textsplitter/CommandlineHandler.java +++ b/src/main/java/eu/svjatoslav/meviz/textsplitter/CommandlineHandler.java @@ -1,7 +1,7 @@ /* * Meviz - Various tools collection to work with multimedia. * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License * as published by the Free Software Foundation. @@ -14,7 +14,7 @@ import java.io.File; import eu.svjatoslav.commons.commandline.parameterparser.Parser; import eu.svjatoslav.commons.commandline.parameterparser.parameter.DirectoryParameter; import eu.svjatoslav.commons.commandline.parameterparser.parameter.NullParameter; -import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameter; +import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameters; public class CommandlineHandler { @@ -23,12 +23,12 @@ public class CommandlineHandler { NullParameter recursiveParameter = parser.createNullParameter( "Enable recursive mode.").addAliases("-r", "--recursive"); - StringParameter fileInputPatternsParameter = parser - .createStringParameter("File input pattern.") + StringParameters fileInputPatternsParameter = parser + .createStringParameters("File input pattern.") .addAliases("-i", "--input-pattern").setMandatory(); - StringParameter splitPatternsParameter = parser - .createStringParameter("File split regular expression.") + StringParameters splitPatternsParameter = parser + .createStringParameters("File split regular expression.") .addAliases("-s", "--split-pattern").setMandatory(); DirectoryParameter workingDirectoryParameter = parser @@ -52,11 +52,10 @@ public class CommandlineHandler { if (fileInputPatternsParameter.isParameterSpecified()) options.fileInputPatterns.addAll(fileInputPatternsParameter - .getArgumentsAsStrings()); + .getValue()); if (splitPatternsParameter.isParameterSpecified()) - options.textSplitPatterns.addAll(splitPatternsParameter - .getArgumentsAsStrings()); + options.textSplitPatterns.addAll(splitPatternsParameter.getValue()); return options; } diff --git a/src/main/java/eu/svjatoslav/meviz/texttruncate/CommandlineHandler.java b/src/main/java/eu/svjatoslav/meviz/texttruncate/CommandlineHandler.java index 005a828..cad7c22 100755 --- a/src/main/java/eu/svjatoslav/meviz/texttruncate/CommandlineHandler.java +++ b/src/main/java/eu/svjatoslav/meviz/texttruncate/CommandlineHandler.java @@ -1,7 +1,7 @@ /* * Meviz - Various tools collection to work with multimedia. * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License * as published by the Free Software Foundation. @@ -14,7 +14,7 @@ import java.io.File; import eu.svjatoslav.commons.commandline.parameterparser.Parser; import eu.svjatoslav.commons.commandline.parameterparser.parameter.DirectoryParameter; import eu.svjatoslav.commons.commandline.parameterparser.parameter.NullParameter; -import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameter; +import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameters; public class CommandlineHandler { @@ -23,7 +23,7 @@ public class CommandlineHandler { NullParameter recursiveParameter = parser.createNullParameter( "Enable recursive mode.").addAliases("-r", "--recursive"); - StringParameter inputPatternParameter = parser.createStringParameter( + StringParameters inputPatternParameter = parser.createStringParameters( "File input pattern.").addAliases("-i", "--input-pattern"); DirectoryParameter workingDirectoryParameter = parser @@ -41,14 +41,12 @@ public class CommandlineHandler { options.recursive = true; if (workingDirectoryParameter.isParameterSpecified()) - options.targetDirectory = workingDirectoryParameter - .getArgumentsAsFiles().get(0); + options.targetDirectory = workingDirectoryParameter.getValue(); else options.targetDirectory = new File(System.getProperty("user.dir")); if (inputPatternParameter.isParameterSpecified()) - options.inputPatterns.addAll(inputPatternParameter - .getArgumentsAsStrings()); + options.inputPatterns.addAll(inputPatternParameter.getValue()); return options; }