package seedu.emeraldo.logic.commands;


/**
 * Lists all tasks in Emeraldo to the user.
 */
//@@author A0139749L
public class ListCommand extends Command {

    public static final String COMMAND_WORD = "list";

    public static final String MESSAGE_LIST_ALL = "Listed all tasks";
    
    public static final String MESSAGE_LIST_UNCOMPLETED = "Listed all uncompleted tasks";
    
    public static final String MESSAGE_LIST_KEYWORD = "Tasks with tag '%s' successfully listed!\n";
    
    public static final String MESSAGE_USAGE = COMMAND_WORD + ": Lists all uncompleted tasks\n"
            + COMMAND_WORD + " [KEYWORD]: Lists all tasks with tags containing the specified keyword (case-sensitive)"
            + "and displays them as a list with index numberss.\n"
            + "Example: " + COMMAND_WORD + " or " + COMMAND_WORD + " homework";

    private String keyword;
    private String successMessage;
    
    public ListCommand(String keyword){
        this.keyword = keyword;
    }
    
    @Override
    public CommandResult execute() {
        if(keyword.isEmpty()){
            model.updateFilteredListToShowUncompleted();
            this.successMessage = MESSAGE_LIST_UNCOMPLETED;
        }else if(keyword.equalsIgnoreCase("all")){
        	model.updateFilteredListToShowAll();
        	this.successMessage = MESSAGE_LIST_ALL;
        }else{
            model.updateFilteredTaskList(keyword);
            this.successMessage = String.format(MESSAGE_LIST_KEYWORD, keyword.toLowerCase())
            		+ getMessageForTaskListShownSummary(model.getFilteredTaskList().size());
        }
        return new CommandResult(successMessage);
    }
}

@@ -527,16 +527,25 @@
 _USAGE =
+ %22(1) %22 +
  COMMAND
@@ -553,17 +553,19 @@
 WORD + %22
-:
+ : 
  Lists a
@@ -592,23 +592,135 @@
 %5Cn%22%0A    
-       
+%09%09+ %22(2) %22 + COMMAND_WORD + %22 %5BPRE-DEFINED KEYWORDS%5D :  Lists all tasks in the period specified%5Cn%22%0A            + %22(3) %22
  + COMMA
@@ -740,17 +740,19 @@
 KEYWORD%5D
-:
+ : 
  Lists a
@@ -806,141 +806,137 @@
 word
- (case-sensitive)%22%0A            + %22and displays them as a list with index numberss.%5Cn%22%0A 
+%5Cn%22%0A            + %22Example:  %22 + COMMAND_WORD + %22
   
+%7C
   
-       + %22Example: %22 + COMMAND_WORD + %22 or
+%22 + COMMAND_WORD + %22 today  %7C  %22 + COMMAND_WORD + %22 tomorrow%22%0A    %09%09+ %22  %7C 
  %22 +
@@ -1465,24 +1465,150 @@
 LL;%0A        
+%7Delse if(keyword.equalsIgnoreCase(%22today%22))%7B%0A        %09%0A        %7Delse if(keyword.equalsIgnoreCase(%22tomorrow%22))%7B%0A        %09%0A    %09
 %7Delse%7B%0A     

Update list command message