package seedu.bulletjournal.logic.parser;

/**
 * Provides variations of commands
 * Note: hard-coded for v0.2, will implement nlp for future versions
 * @author Tu An - arishuynhvan
 */
import static seedu.bulletjournal.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

public class FlexibleCommand {

	private String commandFromUser ="";

	private String[] commandGroups = new String[] {
			"add a adds create creates new",
			"clear clr c clears empty empties",
			"delete d deletes del remove removes rm",
			"edit edits e change changes",
			"exit exits close closes logout logouts",
			"find finds f search searches lookup",
			"help helps h manual instruction instructions",
			"list lists l ls show shows display displays showall",
			"select selects s choose chooses",
	};

	/**
	 * Constructor must take in a valid string input
	 * @param cfu
	 */
	public FlexibleCommand(String cfu){
		commandFromUser = cfu;
	}

	/**
	 * @return the correct command string that matches COMMAND_WORD of command classes
	 */
	public String getCommandWord(){
		for (String commandGroup: commandGroups){
			for (String command: commandGroup.split(" ")){
				if (commandFromUser.equals(command))
					return commandGroup.split(" ")[0];
			}
		}
		return commandFromUser;
	}

	public boolean isValidCommand(){
		for (String commandGroup: commandGroups){
			for (String command: commandGroup.split(" ")){
				if (commandFromUser == command)
					return true;
			}
		}
		return false;
	}
}

@@ -183,96 +183,8 @@
 %0A */
-%0Aimport static seedu.bulletjournal.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
 %0A%0Apu
@@ -212,17 +212,16 @@
 mmand %7B%0A
-%0A
 %09private
@@ -249,13 +249,13 @@
 er =
+ 
 %22%22;%0A
-%0A
 %09pri
@@ -802,16 +802,17 @@
 ing cfu)
+ 
 %7B%0A%09%09comm
@@ -959,16 +959,17 @@
 ndWord()
+ 
 %7B%0A%09%09for 
@@ -996,32 +996,33 @@
 : commandGroups)
+ 
 %7B%0A%09%09%09for (String
@@ -1047,32 +1047,33 @@
 roup.split(%22 %22))
+ 
 %7B%0A%09%09%09%09if (comman
@@ -1210,16 +1210,17 @@
 ommand()
+ 
 %7B%0A%09%09for 
@@ -1255,16 +1255,17 @@
 dGroups)
+ 
 %7B%0A%09%09%09for
@@ -1306,16 +1306,17 @@
 it(%22 %22))
+ 
 %7B%0A%09%09%09%09if
@@ -1336,20 +1336,24 @@
 User
- == 
+.equals(
 command)
 %0A%09%09%09
@@ -1348,16 +1348,17 @@
 command)
+)
 %0A%09%09%09%09%09re

Edit for checkstyle