package seedu.taskboss.logic.parser;

import static seedu.taskboss.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.taskboss.logic.parser.CliSyntax.PREFIX_CATEGORY;
import static seedu.taskboss.logic.parser.CliSyntax.PREFIX_INFORMATION;
import static seedu.taskboss.logic.parser.CliSyntax.PREFIX_PRIORITY;

import java.util.NoSuchElementException;

import seedu.taskboss.commons.exceptions.IllegalValueException;
import seedu.taskboss.logic.commands.AddCommand;
import seedu.taskboss.logic.commands.Command;
import seedu.taskboss.logic.commands.IncorrectCommand;

/**
 * Parses input arguments and creates a new AddCommand object
 */
public class AddCommandParser {

    /**
     * Parses the given {@code String} of arguments in the context of the AddCommand
     * and returns an AddCommand object for execution.
     */
    public Command parse(String args) {
        ArgumentTokenizer argsTokenizer =
                new ArgumentTokenizer(PREFIX_PRIORITY, PREFIX_INFORMATION, PREFIX_CATEGORY);
        argsTokenizer.tokenize(args);
        try {
            return new AddCommand(
                    argsTokenizer.getPreamble().get(),
                    argsTokenizer.getValue(PREFIX_PRIORITY).get(),
                    argsTokenizer.getValue(PREFIX_INFORMATION).get(),
                    ParserUtil.toSet(argsTokenizer.getAllValues(PREFIX_CATEGORY))
            );
        } catch (NoSuchElementException nsee) {
            return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));
        } catch (IllegalValueException ive) {
            return new IncorrectCommand(ive.getMessage());
        }
    }

}

@@ -255,16 +255,81 @@
 MATION;%0A
+import static seedu.taskboss.logic.parser.CliSyntax.PREFIX_NAME;%0A
 import s
@@ -430,16 +430,43 @@
 ception;
+%0Aimport java.util.Optional;
 %0A%0Aimport
@@ -775,16 +775,111 @@
 Parser %7B
+%0A    %0A    private String taskName;%0A    private String priority;%0A    private String information;
 %0A%0A    /*
@@ -1148,16 +1148,29 @@
 kenizer(
+PREFIX_NAME, 
 PREFIX_P
@@ -1344,17 +1344,25 @@
 .get
-Preamble(
+Value(PREFIX_NAME
 ).ge
@@ -1378,32 +1378,43 @@
                 
+checkEmpty(
 argsTokenizer.ge
@@ -1436,21 +1436,16 @@
 RIORITY)
-.get(
 ),%0A     
@@ -1451,32 +1451,43 @@
                 
+checkEmpty(
 argsTokenizer.ge
@@ -1512,21 +1512,16 @@
 RMATION)
-.get(
 ),%0A     
@@ -1896,10 +1896,198 @@
 %0A    %7D%0A%0A
+    private String checkEmpty(Optional%3CString%3E test) %7B%0A        try %7B%0A            return test.get();%0A        %7D catch (NoSuchElementException nsee) %7B%0A            return %22%22;%0A        %7D%0A    %7D%0A%0A
 %7D%0A

make priority & information input optional