diff --git a/src/main/java/backend/CommandParser.java b/src/main/java/backend/CommandParser.java index f464a40..3303caf 100644 --- a/src/main/java/backend/CommandParser.java +++ b/src/main/java/backend/CommandParser.java @@ -18,7 +18,7 @@ public class CommandParser { private static final int POSITION_PARAM_COMMAND = 0; private static final int POSITION_FIRST_PARAM_ARGUMENT = 1; - private static final String REGEX_WHITESPACES = "\\s+"; + private static final String REGEX_WHITESPACES = "[\\s,]+"; private static final String STRING_BACKSLASH = "\\"; private static final String STRING_FORWARD_SLASH = "/"; @@ -176,7 +176,7 @@ private ArrayList findIncludedFileTypes(ArrayList arguments) { if (arguments.contains(KEYWORD_INCLUDE)) { int fileTypesIndex = arguments.indexOf(KEYWORD_INCLUDE) + 1; for (int i = fileTypesIndex; i < arguments.size(); i++) { - String inputFileType = arguments.get(i); + String inputFileType = arguments.get(i).toLowerCase(); if (isValidFileType(inputFileType)) { fileTypes.add(inputFileType); } else { @@ -192,8 +192,7 @@ private ArrayList findIncludedFileTypes(ArrayList arguments) { * * @param inputFileType */ - private boolean isValidFileType(String inputFileType) { - String fileType = inputFileType.trim().toLowerCase(); + private boolean isValidFileType(String fileType) { for (String keyword : KEYWORDS) { if (keyword.equals(fileType)) { return false; diff --git a/src/test/TestCommandParserAndCommand.java b/src/test/TestCommandParserAndCommand.java index 09e4496..c6fb7c0 100644 --- a/src/test/TestCommandParserAndCommand.java +++ b/src/test/TestCommandParserAndCommand.java @@ -57,12 +57,16 @@ public void testCollateCommand() { assertEquals("C:\\", command.getDirectory()); assertFalse(command.willScanCurrentDirOnly()); assertEquals(2, command.getFileTypes().size()); + assertEquals("java", command.getFileTypes().get(0)); + assertEquals("css", command.getFileTypes().get(1)); - command = commandParser.parse("collate include css from C:/"); + command = commandParser.parse("collate include css, FXML from C:/"); assertEquals(Command.Type.COLLATE, command.getCommandType()); assertEquals("C:\\", command.getDirectory()); assertFalse(command.willScanCurrentDirOnly()); - assertEquals(1, command.getFileTypes().size()); + assertEquals(2, command.getFileTypes().size()); + assertEquals("css", command.getFileTypes().get(0)); + assertEquals("fxml", command.getFileTypes().get(1)); command = commandParser.parse("collate include css from \"C:/Program Files\" only"); assertEquals(Command.Type.COLLATE, command.getCommandType());