Skip to content

Commit

Permalink
Merge pull request #183 from dasha3412/branch-addCommandKeywords
Browse files Browse the repository at this point in the history
Add command keywords
  • Loading branch information
riccoljy authored Oct 31, 2024
2 parents 8ab0191 + fc24685 commit 75e64a2
Show file tree
Hide file tree
Showing 16 changed files with 123 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class CreateTagCommand extends Command {

public static final String COMMAND_WORD = "create-tag";

public static final String COMMAND_KEYWORD = "ctag";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Creates a tag in the address book. \n"
+ "Parameters: "
+ PREFIX_TAG + "TAG\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class CreateTaskCommand extends Command {

public static final String COMMAND_WORD = "create-task";

public static final String COMMAND_KEYWORD = "ctask";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Creates a task in the address book. \n"
+ "Parameters: "
+ PREFIX_TASK + "TASK_TYPE TASK_DESCRIPTION [ADDITIONAL_FIELDS]\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
public class DeleteTagCommand extends Command {
public static final String COMMAND_WORD = "delete-tag";

public static final String COMMAND_KEYWORD = "dtag";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Deletes the tag identified by the tag name.\n"
+ "Parameters: " + PREFIX_TAG + "TAG (must exist in the AddressBook)\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class DeleteTaskCommand extends Command {

public static final String COMMAND_WORD = "delete-task";

public static final String COMMAND_KEYWORD = "dtask";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Deletes the task identified by the index number used in the displayed task list.\n"
+ "Parameters: INDEX (must be a positive integer)\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class ListTasksCommand extends Command {

public static final String COMMAND_WORD = "list-tasks";

public static final String COMMAND_KEYWORD = "lt";

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class AddVendorCommand extends Command {

public static final String COMMAND_WORD = "add-vendor";

public static final String COMMAND_KEYWORD = "addv";

// to add task field prefix and example at the end
public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Adds 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 @@ -20,6 +20,8 @@ public class AssignVendorCommand extends Command {

public static final String COMMAND_WORD = "assign-vendor";

public static final String COMMAND_KEYWORD = "asv";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Assigns the person identified by the index number used in the last person listing "
+ "as a vendor.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class UnassignVendorCommand extends Command {

public static final String COMMAND_WORD = "unassign-vendor";

public static final String COMMAND_KEYWORD = "uv";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Unassigns the vendor identified by the index number used in the displayed person list.\n"
+ " The person becomes a normal contact in the addressbook and cannot have tasks assigned to it.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class AssignWeddingCommand extends Command {

public static final String COMMAND_WORD = "assign-wedding";

public static final String COMMAND_KEYWORD = "asw";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Adds one or multiple weddings to 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 @@ -18,6 +18,8 @@ public class CreateWeddingCommand extends Command {

public static final String COMMAND_WORD = "create-wedding";

public static final String COMMAND_KEYWORD = "cw";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Creates a wedding in the address book. "
+ "Wedding names are case sensitive.\n"
+ "Parameters: "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
public class DeleteWeddingCommand extends Command {
public static final String COMMAND_WORD = "delete-wedding";

public static final String COMMAND_KEYWORD = "dw";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Deletes the wedding identified by the wedding name. Wedding names are case sensitive.\n"
+ "Parameters: " + PREFIX_WEDDING + "WEDDING (must exist in the Wedlinker)\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class EditWeddingCommand extends Command {

public static final String COMMAND_WORD = "edit-wedding";

public static final String COMMAND_KEYWORD = "ew";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the wedding identified "
+ "by the index number used in the displayed wedding list. "
+ "Existing values will be overwritten by the input values.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
public class ListWeddingsCommand extends Command {

public static final String COMMAND_WORD = "list-weddings";
public static final String COMMAND_KEYWORD = "lw";

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
public class UnassignWeddingCommand extends Command {
public static final String COMMAND_WORD = "unassign-wedding";

public static final String COMMAND_KEYWORD = "uw";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Removes one or multiple weddings from the person identified "
+ "by the index number used in the last person listing.\n"
Expand Down
42 changes: 27 additions & 15 deletions src/main/java/seedu/address/logic/parser/AddressBookParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,37 @@ public Command parseCommand(String userInput) throws ParseException {
case ClearCommand.COMMAND_WORD -> new ClearCommand();
case FindCommand.COMMAND_WORD -> new FindCommandParser().parse(arguments);
case ListCommand.COMMAND_WORD -> new ListCommand();
case ListWeddingsCommand.COMMAND_WORD -> new ListWeddingsCommand();
case ListWeddingsCommand.COMMAND_WORD, ListWeddingsCommand.COMMAND_KEYWORD -> new ListWeddingsCommand();
case ExitCommand.COMMAND_WORD -> new ExitCommand();
case HelpCommand.COMMAND_WORD -> new HelpCommand();
case CreateTagCommand.COMMAND_WORD -> new CreateTagCommandParser().parse(arguments);
case DeleteTagCommand.COMMAND_WORD -> new DeleteTagCommandParser().parse(arguments);
case EditWeddingCommand.COMMAND_WORD -> new EditWeddingCommandParser().parse(arguments);
case CreateWeddingCommand.COMMAND_WORD -> new CreateWeddingCommandParser().parse(arguments);
case DeleteWeddingCommand.COMMAND_WORD -> new DeleteWeddingCommandParser().parse(arguments);
case CreateTagCommand.COMMAND_WORD, CreateTagCommand.COMMAND_KEYWORD
-> new CreateTagCommandParser().parse(arguments);
case DeleteTagCommand.COMMAND_WORD, DeleteTagCommand.COMMAND_KEYWORD
-> new DeleteTagCommandParser().parse(arguments);
case EditWeddingCommand.COMMAND_WORD, EditWeddingCommand.COMMAND_KEYWORD
-> new EditWeddingCommandParser().parse(arguments);
case CreateWeddingCommand.COMMAND_WORD, CreateWeddingCommand.COMMAND_KEYWORD
-> new CreateWeddingCommandParser().parse(arguments);
case DeleteWeddingCommand.COMMAND_WORD, DeleteWeddingCommand.COMMAND_KEYWORD
-> new DeleteWeddingCommandParser().parse(arguments);
case TagCommand.COMMAND_WORD -> new TagCommandParser().parse(arguments);
case UntagCommand.COMMAND_WORD -> new UntagCommandParser().parse(arguments);
case AssignWeddingCommand.COMMAND_WORD -> new AssignWeddingCommandParser().parse(arguments);
case UnassignWeddingCommand.COMMAND_WORD -> new UnassignWeddingCommandParser().parse(arguments);
case AssignVendorCommand.COMMAND_WORD -> new AssignVendorCommandParser().parse(arguments);
case AddVendorCommand.COMMAND_WORD -> new AddVendorCommandParser().parse(arguments);
case UnassignVendorCommand.COMMAND_WORD -> new UnassignVendorCommandParser().parse(arguments);
case CreateTaskCommand.COMMAND_WORD -> new CreateTaskCommandParser().parse(arguments);
case ListTasksCommand.COMMAND_WORD -> new ListTasksCommand();
case DeleteTaskCommand.COMMAND_WORD -> new DeleteTaskCommandParser().parse(arguments);

case AssignWeddingCommand.COMMAND_WORD, AssignWeddingCommand.COMMAND_KEYWORD
-> new AssignWeddingCommandParser().parse(arguments);
case UnassignWeddingCommand.COMMAND_WORD, UnassignWeddingCommand.COMMAND_KEYWORD
-> new UnassignWeddingCommandParser().parse(arguments);
case CreateTaskCommand.COMMAND_WORD, CreateTaskCommand.COMMAND_KEYWORD
-> new CreateTaskCommandParser().parse(arguments);
case ListTasksCommand.COMMAND_WORD, ListTasksCommand.COMMAND_KEYWORD
-> new ListTasksCommand();
case DeleteTaskCommand.COMMAND_WORD, DeleteTaskCommand.COMMAND_KEYWORD
-> new DeleteTaskCommandParser().parse(arguments);
case AssignVendorCommand.COMMAND_WORD, AssignVendorCommand.COMMAND_KEYWORD
-> new AssignVendorCommandParser().parse(arguments);
case AddVendorCommand.COMMAND_WORD, AddVendorCommand.COMMAND_KEYWORD
-> new AddVendorCommandParser().parse(arguments);
case UnassignVendorCommand.COMMAND_WORD, UnassignVendorCommand.COMMAND_KEYWORD
-> new UnassignVendorCommandParser().parse(arguments);
default -> {
logger.finer("This user input caused a ParseException: " + userInput);
throw new ParseException(MESSAGE_UNKNOWN_COMMAND);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ public void parseCommand_createTag() throws Exception {

CreateTagCommand command = (CreateTagCommand) parser.parseCommand(userInput);
assertEquals(expectedCommand, command);

// Test using create tag keyword
String userKeywordInput = CreateTagCommand.COMMAND_KEYWORD + " t/colleague";
CreateTagCommand keywordCommand = (CreateTagCommand) parser.parseCommand(userKeywordInput);
assertEquals(expectedCommand, keywordCommand);
}

@Test
Expand All @@ -204,6 +209,11 @@ public void parseCommand_deleteTag() throws Exception {

DeleteTagCommand command = (DeleteTagCommand) parser.parseCommand(userInput);
assertEquals(expectedCommand, command);

// Test using delete tag keyword
String userKeywordInput = DeleteTagCommand.COMMAND_KEYWORD + " t/vendor";
DeleteTagCommand keywordCommand = (DeleteTagCommand) parser.parseCommand(userKeywordInput);
assertEquals(expectedCommand, keywordCommand);
}

@Test
Expand All @@ -214,6 +224,11 @@ public void parseCommand_createWedding() throws Exception {

CreateWeddingCommand command = (CreateWeddingCommand) parser.parseCommand(userInput);
assertEquals(expectedCommand, command);

// Test using create wedding keyword
String userKeywordInput = CreateWeddingCommand.COMMAND_KEYWORD + " w/Wedding 19";
CreateWeddingCommand keywordCommand = (CreateWeddingCommand) parser.parseCommand(userKeywordInput);
assertEquals(expectedCommand, keywordCommand);
}

@Test
Expand All @@ -224,6 +239,11 @@ public void parseCommand_deleteWedding() throws Exception {

DeleteWeddingCommand command = (DeleteWeddingCommand) parser.parseCommand(userInput);
assertEquals(expectedCommand, command);

// Test using delete wedding keyword
String userKeywordInput = DeleteWeddingCommand.COMMAND_KEYWORD + " w/Joe's Wedding";
DeleteWeddingCommand keywordCommand = (DeleteWeddingCommand) parser.parseCommand(userKeywordInput);
assertEquals(expectedCommand, keywordCommand);
}

@Test
Expand All @@ -236,6 +256,12 @@ public void parseCommand_assignWedding() throws Exception {

AssignWeddingCommand command = (AssignWeddingCommand) parser.parseCommand(userInput);
assertEquals(expectedCommand, command);

// Test using assign wedding keyword
String userKeywordInput = AssignWeddingCommand.COMMAND_KEYWORD + " " + INDEX_FIRST.getOneBased()
+ " w/Wedding 19 w/Joe's Wedding";
AssignWeddingCommand keywordCommand = (AssignWeddingCommand) parser.parseCommand(userKeywordInput);
assertEquals(expectedCommand, keywordCommand);
}

@Test
Expand All @@ -248,32 +274,64 @@ public void parseCommand_unassignWedding() throws Exception {

UnassignWeddingCommand command = (UnassignWeddingCommand) parser.parseCommand(userInput);
assertEquals(expectedCommand, command);

// Test using unassign wedding keyword
String userKeywordInput = UnassignWeddingCommand.COMMAND_KEYWORD + " " + INDEX_FIRST.getOneBased()
+ " w/Wedding 19 w/Joe's Wedding";
UnassignWeddingCommand keywordCommand = (UnassignWeddingCommand) parser.parseCommand(userKeywordInput);
assertEquals(expectedCommand, keywordCommand);
}

@Test
public void parseCommand_listWeddings() throws Exception {
assertTrue(parser.parseCommand(ListWeddingsCommand.COMMAND_WORD) instanceof ListWeddingsCommand);
assertTrue(parser.parseCommand(ListWeddingsCommand.COMMAND_WORD + " 3") instanceof ListWeddingsCommand);
// Test using list weddings keyword
assertTrue(parser.parseCommand(ListWeddingsCommand.COMMAND_KEYWORD + " 3") instanceof ListWeddingsCommand);
}

@Test
public void parseCommand_listTask() throws Exception {
assertTrue(parser.parseCommand(ListTasksCommand.COMMAND_WORD) instanceof ListTasksCommand);
assertTrue(parser.parseCommand(ListTasksCommand.COMMAND_WORD + " 3") instanceof ListTasksCommand);
// Test using list tasks keyword
assertTrue(parser.parseCommand(ListTasksCommand.COMMAND_KEYWORD + " 3") instanceof ListTasksCommand);
}

@Test
public void parseCommand_deleteTask() throws Exception {
DeleteTaskCommand command = (DeleteTaskCommand) parser.parseCommand(
DeleteTaskCommand.COMMAND_WORD + " " + INDEX_FIRST.getOneBased());
assertEquals(new DeleteTaskCommand(INDEX_FIRST), command);

// Test using delete task keyword
DeleteTaskCommand keywordCommand = (DeleteTaskCommand) parser.parseCommand(
DeleteTaskCommand.COMMAND_KEYWORD + " " + INDEX_FIRST.getOneBased());
assertEquals(new DeleteTaskCommand(INDEX_FIRST), keywordCommand);
}

@Test
public void parseCommand_assignVendor() throws Exception {
AssignVendorCommand command = (AssignVendorCommand) parser.parseCommand(
AssignVendorCommand.COMMAND_WORD + " " + INDEX_FIRST.getOneBased());
assertEquals(new AssignVendorCommand(INDEX_FIRST), command);

// Test using assign vendor keyword
AssignVendorCommand keywordCommand = (AssignVendorCommand) parser.parseCommand(
AssignVendorCommand.COMMAND_KEYWORD + " " + INDEX_FIRST.getOneBased());
assertEquals(new AssignVendorCommand(INDEX_FIRST), keywordCommand);
}

@Test
public void parseCommand_unassignVendor() throws Exception {
UnassignVendorCommand command = (UnassignVendorCommand) parser.parseCommand(
UnassignVendorCommand.COMMAND_WORD + " " + INDEX_FIRST.getOneBased());
assertEquals(new UnassignVendorCommand(INDEX_FIRST), command);

// Test using unassign vendor keyword
UnassignVendorCommand keywordCommand = (UnassignVendorCommand) parser.parseCommand(
UnassignVendorCommand.COMMAND_KEYWORD + " " + INDEX_FIRST.getOneBased());
assertEquals(new UnassignVendorCommand(INDEX_FIRST), keywordCommand);
}

@Test
Expand All @@ -282,6 +340,11 @@ public void parseCommand_addVendor() throws Exception {
String userInput = AddVendorCommand.COMMAND_WORD + " n/Alison Longwood";
AddVendorCommand command = (AddVendorCommand) parser.parseCommand(userInput);
assertEquals(new AddVendorCommand(vendor), command);

// Test using add vendor keyword
String userKeywordInput = AddVendorCommand.COMMAND_KEYWORD + " n/Alison Longwood";
AddVendorCommand keywordCommand = (AddVendorCommand) parser.parseCommand(userKeywordInput);
assertEquals(new AddVendorCommand(vendor), keywordCommand);
}

@Test
Expand All @@ -295,13 +358,13 @@ public void parseCommand_createTask() throws Exception {
CreateTaskCommand command = (CreateTaskCommand) parser.parseCommand(userInput);

assertEquals(expectedCommand, command);
}

@Test
public void parseCommand_deleteTask() throws Exception {
DeleteTaskCommand command = (DeleteTaskCommand) parser.parseCommand(
DeleteTaskCommand.COMMAND_WORD + " " + INDEX_FIRST.getOneBased());
assertEquals(new DeleteTaskCommand(INDEX_FIRST), command);
// Test using create task keyword
String userKeywordInput = CreateTaskCommand.COMMAND_KEYWORD
+ " tk/todo Buy groceries tk/deadline Submit report /by 2024-12-31"
+ " tk/event Project meeting /from 2024-10-10 /to 2024-10-11";
CreateTaskCommand keywordCommand = (CreateTaskCommand) parser.parseCommand(userKeywordInput);
assertEquals(expectedCommand, keywordCommand);
}


Expand Down

0 comments on commit 75e64a2

Please sign in to comment.