Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.

Logic: Add alias for commands #590

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
public class AddCommand extends UndoableCommand {

public static final String COMMAND_WORD = "add";
public static final String COMMAND_ALIAS = "a";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. "
+ "Parameters: "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class ClearCommand extends UndoableCommand {

public static final String COMMAND_WORD = "clear";
public static final String COMMAND_ALIAS = "c";
public static final String MESSAGE_SUCCESS = "Address book has been cleared!";


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
public class DeleteCommand extends UndoableCommand {

public static final String COMMAND_WORD = "delete";
public static final String COMMAND_ALIAS = "d";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Deletes the person identified by the index number used in the last person listing.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
public class EditCommand extends UndoableCommand {

public static final String COMMAND_WORD = "edit";
public static final String COMMAND_ALIAS = "e";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the person identified "
+ "by the index number used in the last person listing. "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
public class FindCommand extends Command {

public static final String COMMAND_WORD = "find";
public static final String COMMAND_ALIAS = "f";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of "
+ "the specified keywords (case-sensitive) and displays them as a list with index numbers.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
public class HistoryCommand extends Command {

public static final String COMMAND_WORD = "history";
public static final String COMMAND_ALIAS = "h";
public static final String MESSAGE_SUCCESS = "Entered commands (from most recent to earliest):\n%1$s";
public static final String MESSAGE_NO_HISTORY = "You have not yet entered any commands.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
public class ListCommand extends Command {

public static final String COMMAND_WORD = "list";
public static final String COMMAND_ALIAS = "l";

public static final String MESSAGE_SUCCESS = "Listed all persons";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
public class RedoCommand extends Command {

public static final String COMMAND_WORD = "redo";
public static final String COMMAND_ALIAS = "r";
public static final String MESSAGE_SUCCESS = "Redo success!";
public static final String MESSAGE_FAILURE = "No more commands to redo!";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
public class SelectCommand extends Command {

public static final String COMMAND_WORD = "select";
public static final String COMMAND_ALIAS = "s";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Selects the person identified by the index number used in the last person listing.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
public class UndoCommand extends Command {

public static final String COMMAND_WORD = "undo";
public static final String COMMAND_ALIAS = "u";
public static final String MESSAGE_SUCCESS = "Undo success!";
public static final String MESSAGE_FAILURE = "No more commands to undo!";

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/seedu/address/logic/parser/AddressBookParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,35 @@ public Command parseCommand(String userInput) throws ParseException {
switch (commandWord) {

case AddCommand.COMMAND_WORD:
case AddCommand.COMMAND_ALIAS:
return new AddCommandParser().parse(arguments);

case EditCommand.COMMAND_WORD:
case EditCommand.COMMAND_ALIAS:
return new EditCommandParser().parse(arguments);

case SelectCommand.COMMAND_WORD:
case SelectCommand.COMMAND_ALIAS:
return new SelectCommandParser().parse(arguments);

case DeleteCommand.COMMAND_WORD:
case DeleteCommand.COMMAND_ALIAS:
return new DeleteCommandParser().parse(arguments);

case ClearCommand.COMMAND_WORD:
case ClearCommand.COMMAND_ALIAS:
return new ClearCommand();

case FindCommand.COMMAND_WORD:
case FindCommand.COMMAND_ALIAS:
return new FindCommandParser().parse(arguments);

case ListCommand.COMMAND_WORD:
case ListCommand.COMMAND_ALIAS:
return new ListCommand();

case HistoryCommand.COMMAND_WORD:
case HistoryCommand.COMMAND_ALIAS:
return new HistoryCommand();

case ExitCommand.COMMAND_WORD:
Expand All @@ -79,9 +87,11 @@ public Command parseCommand(String userInput) throws ParseException {
return new HelpCommand();

case UndoCommand.COMMAND_WORD:
case UndoCommand.COMMAND_ALIAS:
return new UndoCommand();

case RedoCommand.COMMAND_WORD:
case RedoCommand.COMMAND_ALIAS:
return new RedoCommand();

default:
Expand Down