package watodo.logic.parser;

import static watodo.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static watodo.logic.parser.CliSyntax.KEYWORDS_ARGS_FORMAT;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;

import watodo.logic.commands.Command;
import watodo.logic.commands.IncorrectCommand;
import watodo.logic.commands.MarkCommand;

//@@author A0164393Y

/**
 * Parses input arguments and creates a new FindCommand object
 */
public class MarkCommandParser {

    /**
     * Parses the given {@code String} of arguments in the context of the FindCommand
     * and returns an FindCommand object for execution.
     */
    public Command parse(String args) {
        final Matcher matcher = KEYWORDS_ARGS_FORMAT.matcher(args.trim());
        if (!matcher.matches()) {
            return new IncorrectCommand(
                    String.format(MESSAGE_INVALID_COMMAND_FORMAT, MarkCommand.MESSAGE_USAGE));
        }

        // keywords delimited by whitespace
        final String[] keywords = matcher.group("keywords").split("\\s+");
        final Set<String> keywordSet = new HashSet<>(Arrays.asList(keywords));
        return new MarkCommand(keywordSet);
    }

}

@@ -469,20 +469,20 @@
 s a new 
-Find
+Mark
 Command 
@@ -608,20 +608,20 @@
  of the 
-Find
+Mark
 Command%0A
@@ -646,12 +646,12 @@
  an 
-Find
+Mark
 Comm

edit comments