/** @@author A0142130A **/
package seedu.taskell.logic.commands;

import seedu.taskell.commons.core.EventsCenter;
import seedu.taskell.commons.events.ui.DisplayListChangedEvent;
import seedu.taskell.model.History;
import seedu.taskell.model.HistoryManager;

/** Lists a list of previous commands available for Undo operation
 * */
public class ViewHistoryCommand extends Command {
    
    public static final String COMMAND_WORD_1 = "history";
    public static final String COMMAND_WORD_2 = "hist";

    public static final String MESSAGE_SUCCESS = "Listed all commands available for undo.";
    
    private static ViewHistoryCommand self;
    
    public ViewHistoryCommand() {}
    
    public static ViewHistoryCommand getInstance() {
        if (self == null) {
            self = new ViewHistoryCommand();
        }
        
        return self;
    }

    @Override
    public CommandResult execute() {
        indicateDisplayListChanged();
        return new CommandResult(MESSAGE_SUCCESS);
    }

    public void indicateDisplayListChanged() {
        EventsCenter.getInstance().post(
                new DisplayListChangedEvent(history.getListCommandText()));
    }

}

@@ -587,16 +587,98 @@
 undo.%22;%0A
+    public static final String MESSAGE_UNSUCCESSFUL = %22Error displaying history%22;%0A
     %0A   
@@ -983,24 +983,42 @@
 execute() %7B%0A
+        try %7B%0A    
         indi
@@ -1039,24 +1039,126 @@
 tChanged();%0A
+        %7D catch (Exception e) %7B%0A            return new CommandResult(MESSAGE_UNSUCCESSFUL);%0A        %7D%0A
         retu

add error message if fail to show history