package utask.logic.parser;

import static utask.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static utask.logic.parser.CliSyntax.PREFIX_DEADLINE;
import static utask.logic.parser.CliSyntax.PREFIX_DONE;
import static utask.logic.parser.CliSyntax.PREFIX_FREQUENCY;
import static utask.logic.parser.CliSyntax.PREFIX_TAG;
import static utask.logic.parser.CliSyntax.PREFIX_TIMESTAMP;

import java.util.NoSuchElementException;

import utask.commons.exceptions.IllegalValueException;
import utask.logic.commands.Command;
import utask.logic.commands.CreateCommand;
import utask.logic.commands.CreateDeadlineTaskCommand;
import utask.logic.commands.CreateEventTaskCommand;
import utask.logic.commands.CreateFloatingTaskCommand;
import utask.logic.commands.IncorrectCommand;

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

    /**
     * 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_DEADLINE, PREFIX_TIMESTAMP, PREFIX_FREQUENCY, PREFIX_TAG, PREFIX_DONE);
        argsTokenizer.tokenize(args);

        try {
            if (argsTokenizer.getValue(PREFIX_TIMESTAMP).isPresent() &&
                    argsTokenizer.getValue(PREFIX_DEADLINE).isPresent()) {
                return new CreateEventTaskCommand(
                        argsTokenizer.getPreamble().get(),
                        argsTokenizer.getValue(PREFIX_DEADLINE).get(),
                        argsTokenizer.getValue(PREFIX_TIMESTAMP).get(),
                        argsTokenizer.tryGet(PREFIX_FREQUENCY),
                        ParserUtil.toSet(argsTokenizer.getAllValues(PREFIX_TAG)),
                        argsTokenizer.tryGet(PREFIX_DONE)
                );
            } else if (argsTokenizer.getValue(PREFIX_DEADLINE).isPresent()) {
                return new CreateDeadlineTaskCommand(
                        argsTokenizer.getPreamble().get(),
                        argsTokenizer.getValue(PREFIX_DEADLINE).get(),
                        argsTokenizer.tryGet(PREFIX_FREQUENCY),
                        ParserUtil.toSet(argsTokenizer.getAllValues(PREFIX_TAG)),
                        argsTokenizer.tryGet(PREFIX_DONE)
                );
            } else {
                return new CreateFloatingTaskCommand(
                        argsTokenizer.getPreamble().get(),
                        argsTokenizer.tryGet(PREFIX_FREQUENCY),
                        ParserUtil.toSet(argsTokenizer.getAllValues(PREFIX_TAG)),
                        argsTokenizer.tryGet(PREFIX_DONE)
                );
            }
        } catch (NoSuchElementException nsee) {
            return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, CreateCommand.MESSAGE_USAGE));
        } catch (IllegalValueException ive) {
            return new IncorrectCommand(ive.getMessage());
        }
    }

}

@@ -1275,17 +1275,46 @@
 (args);%0A
+        String deadline = %22%22;
 %0A
-
         
@@ -1458,32 +1458,137 @@
 .isPresent()) %7B%0A
+                deadline = getDateFromMeaningfulDeadline(argsTokenizer.getValue(PREFIX_DEADLINE).get());%0A
                 
@@ -1709,53 +1709,16 @@
     
-argsTokenizer.getValue(PREFIX_DEADLINE).get()
+deadline
 ,%0A  
@@ -2080,32 +2080,137 @@
 .isPresent()) %7B%0A
+                deadline = getDateFromMeaningfulDeadline(argsTokenizer.getValue(PREFIX_DEADLINE).get());%0A
                 
@@ -2334,53 +2334,16 @@
     
-argsTokenizer.getValue(PREFIX_DEADLINE).get()
+deadline
 ,%0A  
@@ -3221,10 +3221,407 @@
 %0A    %7D%0A%0A
+    //TODO: Fake demo make it real%0A    private String getDateFromMeaningfulDeadline(String deadline) %7B%0A        if (deadline.equals(%22today%22)) %7B%0A            return %22060417%22;%0A        %7D else if (deadline.equals(%22tmr%22) %7C deadline.equals(%22tomorrow%22)) %7B%0A            return %22070417%22;%0A        %7D else if (deadline.equals(%22next week%22)) %7B%0A            return %22130417%22;%0A        %7D%0A        return deadline;%0A    %7D%0A
 %7D%0A

Add mock demo code