forked from nus-cs2103-AY1718S1/addressbook-level4-old
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from Pengyuz/master
Helpcommand
- Loading branch information
Showing
12 changed files
with
269 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/main/java/seedu/address/logic/parser/HelpCommandParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import seedu.address.logic.commands.AddCommand; | ||
import seedu.address.logic.commands.ClearCommand; | ||
import seedu.address.logic.commands.DeleteCommand; | ||
import seedu.address.logic.commands.EditCommand; | ||
import seedu.address.logic.commands.ExitCommand; | ||
import seedu.address.logic.commands.FindCommand; | ||
import seedu.address.logic.commands.HelpCommand; | ||
import seedu.address.logic.commands.HistoryCommand; | ||
import seedu.address.logic.commands.ListCommand; | ||
import seedu.address.logic.commands.RedoCommand; | ||
import seedu.address.logic.commands.SelectCommand; | ||
import seedu.address.logic.commands.SortCommand; | ||
import seedu.address.logic.commands.TagAddCommand; | ||
import seedu.address.logic.commands.TagRemoveCommand; | ||
import seedu.address.logic.commands.UndoCommand; | ||
|
||
import seedu.address.logic.parser.exceptions.ParseException; | ||
|
||
|
||
/** | ||
* Parses input arguments and creates a new SelectCommand object | ||
*/ | ||
public class HelpCommandParser implements Parser<HelpCommand> { | ||
|
||
/** | ||
* Parses the given {@code String} of arguments in the context of the SelectCommand | ||
* and returns an SelectCommand object for execution. | ||
*/ | ||
public HelpCommand parse(String args) throws ParseException { | ||
String input = args.toLowerCase().trim(); | ||
|
||
if (input.equals(AddCommand.COMMAND_WORD) || input.equals(AddCommand.COMMAND_WORD_2) | ||
|| input.equals(AddCommand.COMMAND_WORD_3)) { | ||
return new HelpCommand("add"); | ||
} else if (input.equals(ClearCommand.COMMAND_WORD)) { | ||
return new HelpCommand("clear"); | ||
} else if (input.equals(DeleteCommand.COMMAND_WORD) || input.equals(DeleteCommand.COMMAND_WORD_2) | ||
|| input.equals(DeleteCommand.COMMAND_WORD_3)) { | ||
return new HelpCommand("delete"); | ||
} else if (input.equals(EditCommand.COMMAND_WORD) || input.equals(EditCommand.COMMAND_WORD_2) | ||
|| input.equals(EditCommand.COMMAND_WORD_3)) { | ||
return new HelpCommand("edit"); | ||
} else if (input.equals(ExitCommand.COMMAND_WORD)) { | ||
return new HelpCommand("exit"); | ||
} else if (input.equals(FindCommand.COMMAND_WORD) || input.equals(FindCommand.COMMAND_WORD_2) | ||
|| input.equals(FindCommand.COMMAND_WORD_3)) { | ||
return new HelpCommand("find"); | ||
} else if (input.equals(HistoryCommand.COMMAND_WORD) || input.equals(HistoryCommand.COMMAND_WORD_2)) { | ||
return new HelpCommand("history"); | ||
} else if (input.equals(ListCommand.COMMAND_WORD) || input.equals(ListCommand.COMMAND_WORD_2) | ||
|| input.equals(ListCommand.COMMAND_WORD_3)) { | ||
return new HelpCommand("list"); | ||
} else if (input.equals(RedoCommand.COMMAND_WORD)) { | ||
return new HelpCommand("redo"); | ||
} else if (input.equals(SelectCommand.COMMAND_WORD) || input.equals(SelectCommand.COMMAND_WORD_2)) { | ||
return new HelpCommand("select"); | ||
} else if (input.equals(SortCommand.COMMAND_WORD)) { | ||
return new HelpCommand("sort"); | ||
} else if (input.equals(TagAddCommand.COMMAND_WORD)) { | ||
return new HelpCommand("tagadd"); | ||
} else if (input.equals(TagRemoveCommand.COMMAND_WORD)) { | ||
return new HelpCommand("tagremove"); | ||
} else if (input.equals(UndoCommand.COMMAND_WORD)) { | ||
return new HelpCommand("undo"); | ||
} else { | ||
return new HelpCommand(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
src/test/java/seedu/address/logic/parser/HelpCommandParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; | ||
|
||
import org.junit.Test; | ||
|
||
import seedu.address.logic.commands.AddCommand; | ||
import seedu.address.logic.commands.ClearCommand; | ||
import seedu.address.logic.commands.DeleteCommand; | ||
import seedu.address.logic.commands.EditCommand; | ||
import seedu.address.logic.commands.ExitCommand; | ||
import seedu.address.logic.commands.FindCommand; | ||
import seedu.address.logic.commands.HelpCommand; | ||
import seedu.address.logic.commands.HistoryCommand; | ||
import seedu.address.logic.commands.ListCommand; | ||
import seedu.address.logic.commands.RedoCommand; | ||
import seedu.address.logic.commands.SelectCommand; | ||
import seedu.address.logic.commands.SortCommand; | ||
import seedu.address.logic.commands.TagAddCommand; | ||
import seedu.address.logic.commands.TagRemoveCommand; | ||
import seedu.address.logic.commands.UndoCommand; | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
public class HelpCommandParserTest { | ||
private HelpCommandParser parser = new HelpCommandParser(); | ||
|
||
@Test | ||
public void parsesuccess() { | ||
assertParseSuccess(parser, AddCommand.COMMAND_WORD, new HelpCommand("add")); | ||
|
||
assertParseSuccess(parser, AddCommand.COMMAND_WORD_2, new HelpCommand("add")); | ||
|
||
assertParseSuccess(parser, AddCommand.COMMAND_WORD_3, new HelpCommand("add")); | ||
|
||
assertParseSuccess(parser, ClearCommand.COMMAND_WORD, new HelpCommand("clear")); | ||
|
||
assertParseSuccess(parser, DeleteCommand.COMMAND_WORD, new HelpCommand("delete")); | ||
|
||
assertParseSuccess(parser, DeleteCommand.COMMAND_WORD_2, new HelpCommand("delete")); | ||
|
||
assertParseSuccess(parser, DeleteCommand.COMMAND_WORD_3, new HelpCommand("delete")); | ||
|
||
assertParseSuccess(parser, EditCommand.COMMAND_WORD, new HelpCommand("edit")); | ||
|
||
assertParseSuccess(parser, EditCommand.COMMAND_WORD_2, new HelpCommand("edit")); | ||
|
||
assertParseSuccess(parser, EditCommand.COMMAND_WORD_3, new HelpCommand("edit")); | ||
|
||
assertParseSuccess(parser, ExitCommand.COMMAND_WORD, new HelpCommand("exit")); | ||
|
||
assertParseSuccess(parser, FindCommand.COMMAND_WORD, new HelpCommand("find")); | ||
|
||
assertParseSuccess(parser, FindCommand.COMMAND_WORD_2, new HelpCommand("find")); | ||
|
||
assertParseSuccess(parser, FindCommand.COMMAND_WORD_3, new HelpCommand("find")); | ||
|
||
assertParseSuccess(parser, HistoryCommand.COMMAND_WORD, new HelpCommand("history")); | ||
|
||
assertParseSuccess(parser, HistoryCommand.COMMAND_WORD_2, new HelpCommand("history")); | ||
|
||
assertParseSuccess(parser, ListCommand.COMMAND_WORD, new HelpCommand("list")); | ||
|
||
assertParseSuccess(parser, ListCommand.COMMAND_WORD_2, new HelpCommand("list")); | ||
|
||
assertParseSuccess(parser, ListCommand.COMMAND_WORD_3, new HelpCommand("list")); | ||
|
||
assertParseSuccess(parser, RedoCommand.COMMAND_WORD, new HelpCommand("redo")); | ||
|
||
assertParseSuccess(parser, SelectCommand.COMMAND_WORD, new HelpCommand("select")); | ||
|
||
assertParseSuccess(parser, SelectCommand.COMMAND_WORD_2, new HelpCommand("select")); | ||
|
||
assertParseSuccess(parser, SortCommand.COMMAND_WORD, new HelpCommand("sort")); | ||
|
||
assertParseSuccess(parser, TagAddCommand.COMMAND_WORD, new HelpCommand("tagadd")); | ||
|
||
assertParseSuccess(parser, TagRemoveCommand.COMMAND_WORD, new HelpCommand("tagremove")); | ||
|
||
assertParseSuccess(parser, UndoCommand.COMMAND_WORD, new HelpCommand("undo")); | ||
|
||
} | ||
|
||
} |