This commit is contained in:
		| @@ -100,18 +100,18 @@ public class Main { | |||||||
|        WRITER.flush(); |        WRITER.flush(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private enum converterArgumentValueType { |     enum converterArgumentValueType { | ||||||
|         BOOLEAN, |         BOOLEAN, | ||||||
|         COMMA_SEPARATED_LIST, |         COMMA_SEPARATED_LIST, | ||||||
|         SINGLE_VALUE, |         SINGLE_VALUE, | ||||||
|         INT |         INT | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static class converterArgument { |     static class converterArgument { | ||||||
|         private String name; |         private String name; | ||||||
|         private boolean valueRequired; |         private boolean valueRequired; | ||||||
|         private converterArgumentValueType valueType; |         private converterArgumentValueType valueType; | ||||||
|         private converterArgument(String name, boolean valueRequired, converterArgumentValueType valueType) { |         converterArgument(String name, boolean valueRequired, converterArgumentValueType valueType) { | ||||||
|             this.name = name; |             this.name = name; | ||||||
|             this.valueRequired = valueRequired; |             this.valueRequired = valueRequired; | ||||||
|             this.valueType = valueType; |             this.valueType = valueType; | ||||||
| @@ -140,33 +140,6 @@ public class Main { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static void parser(List<String> tokens) { |  | ||||||
|         String[] types = {"animeconverter", "audioconverter", "videoconverter"}; |  | ||||||
|         converterArgument[] commonArgs = { |  | ||||||
|                 new converterArgument("-recursions", true, converterArgumentValueType.INT) |  | ||||||
|         }; |  | ||||||
|         converterArgument[] animeArgs = { |  | ||||||
|  |  | ||||||
|         }; |  | ||||||
|         converterArgument[] audioArgs = { |  | ||||||
|                 new converterArgument("-outext", true, converterArgumentValueType.SINGLE_VALUE) |  | ||||||
|         }; |  | ||||||
|         converterArgument[] videoArgs = { |  | ||||||
|                 new converterArgument("-outext", true, converterArgumentValueType.SINGLE_VALUE) |  | ||||||
|         }; |  | ||||||
|         String type = tokens.get(0).toLowerCase(); |  | ||||||
|         if (!listContains(types, s -> s.equals(type))) { |  | ||||||
|             throw new IllegalArgumentException("Unknown converter type chosen."); |  | ||||||
|         } |  | ||||||
|         if (tokens.size() < 2) { |  | ||||||
|             throw new IllegalArgumentException("No file/folder path in argument."); |  | ||||||
|         } |  | ||||||
|         for (int i = 1; i < tokens.size() - 1; i++) { |  | ||||||
|             //TODO: Find the type of argument and check the value |  | ||||||
|             //TODO: Find an executable way to represent the chain of commands parsed |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Initializes the anime converter |      * Initializes the anime converter | ||||||
|      * @throws IOException <p>If reading or writing fails.</p> |      * @throws IOException <p>If reading or writing fails.</p> | ||||||
| @@ -272,7 +245,7 @@ public class Main { | |||||||
|      * @param <T>       Anything which can be stored in a list |      * @param <T>       Anything which can be stored in a list | ||||||
|      * @return          True if at least one element fulfills the predicate |      * @return          True if at least one element fulfills the predicate | ||||||
|      */ |      */ | ||||||
|     private static <T> boolean listContains(T[] list, Predicate<T> predicate) { |     static <T> boolean listContains(T[] list, Predicate<T> predicate) { | ||||||
|         for (T item : list) { |         for (T item : list) { | ||||||
|             if (predicate.test(item)) { |             if (predicate.test(item)) { | ||||||
|                 return true; |                 return true; | ||||||
|   | |||||||
| @@ -3,8 +3,37 @@ package ffmpegconverter; | |||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
|  | import static ffmpegconverter.Main.listContains; | ||||||
|  |  | ||||||
| public class Parser { | public class Parser { | ||||||
|  |  | ||||||
|  |     private static void parse(List<String> tokens) { | ||||||
|  |         String[] types = {"animeconverter", "audioconverter", "videoconverter"}; | ||||||
|  |         Main.converterArgument[] commonArgs = { | ||||||
|  |                 new Main.converterArgument("-recursions", true, Main.converterArgumentValueType.INT) | ||||||
|  |         }; | ||||||
|  |         Main.converterArgument[] animeArgs = { | ||||||
|  |  | ||||||
|  |         }; | ||||||
|  |         Main.converterArgument[] audioArgs = { | ||||||
|  |                 new Main.converterArgument("-outext", true, Main.converterArgumentValueType.SINGLE_VALUE) | ||||||
|  |         }; | ||||||
|  |         Main.converterArgument[] videoArgs = { | ||||||
|  |                 new Main.converterArgument("-outext", true, Main.converterArgumentValueType.SINGLE_VALUE) | ||||||
|  |         }; | ||||||
|  |         String type = tokens.get(0).toLowerCase(); | ||||||
|  |         if (!listContains(types, s -> s.equals(type))) { | ||||||
|  |             throw new IllegalArgumentException("Unknown converter type chosen."); | ||||||
|  |         } | ||||||
|  |         if (tokens.size() < 2) { | ||||||
|  |             throw new IllegalArgumentException("No file/folder path in argument."); | ||||||
|  |         } | ||||||
|  |         for (int i = 1; i < tokens.size() - 1; i++) { | ||||||
|  |             //TODO: Find the type of argument and check the value | ||||||
|  |             //TODO: Find an executable way to represent the chain of commands parsed | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Tokenizes a string |      * Tokenizes a string | ||||||
|      * @param input <p>A string.</p> |      * @param input <p>A string.</p> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user