Skip to content

Commit

Permalink
Merge pull request #106 from HugeNoob/lingxi/shorten-commands
Browse files Browse the repository at this point in the history
feat: Shorten commands
  • Loading branch information
jiakai-17 authored Oct 27, 2023
2 parents 4b52f11 + 9139eb1 commit d5a3d4a
Show file tree
Hide file tree
Showing 24 changed files with 256 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
* Adds a person to the address book.
*/
public class AddPersonCommand extends Command {

public static final String COMMAND_WORD = "addPerson";
public static final String SHORTENED_COMMAND_WORD = "ap";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. "
public static final String MESSAGE_USAGE = COMMAND_WORD + " (alias: " + SHORTENED_COMMAND_WORD + ")"
+ ": Adds a person to the address book.\n"
+ "Parameters: "
+ PREFIX_NAME + "NAME "
+ PREFIX_PHONE + "PHONE "
Expand Down Expand Up @@ -81,6 +84,3 @@ public String toString() {
.toString();
}
}



Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
* Adds a task to the address book.
*/
public class AddTaskCommand extends Command {

public static final String COMMAND_WORD = "addTask";
public static final String SHORTENED_COMMAND_WORD = "at";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a task to the address book. "
public static final String MESSAGE_USAGE = COMMAND_WORD + " (alias: " + SHORTENED_COMMAND_WORD + ")"
+ ": Adds a task to the address book.\n"
+ "Parameters: "
+ PREFIX_TASK_TITLE + "TITLE "
+ PREFIX_TASK_NOTE + "NOTE "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
public class DeleteAllPersonCommand extends Command {

public static final String COMMAND_WORD = "deleteAllPerson";
public static final String SHORTENED_COMMAND_WORD = "dap";

public static final String MESSAGE_DELETE_ALL_PERSON_SUCCESS = "Deleted all persons";

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

public static final String COMMAND_WORD = "deleteAllTask";
public static final String SHORTENED_COMMAND_WORD = "dat";

public static final String MESSAGE_DELETE_ALL_TASK_SUCCESS = "Deleted all tasks";

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
public class DeletePersonCommand extends Command {

public static final String COMMAND_WORD = "deletePerson";
public static final String SHORTENED_COMMAND_WORD = "dp";

public static final String MESSAGE_USAGE = COMMAND_WORD
public static final String MESSAGE_USAGE = COMMAND_WORD + " (alias: " + SHORTENED_COMMAND_WORD + ")"
+ ": Deletes the person identified by the index number used in the displayed person list.\n"
+ "Parameters: INDEX (must be a positive integer)\n"
+ "Example: " + COMMAND_WORD + " 1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
public class DeleteTaskCommand extends Command {

public static final String COMMAND_WORD = "deleteTask";
public static final String SHORTENED_COMMAND_WORD = "dt";

public static final String MESSAGE_USAGE = COMMAND_WORD
public static final String MESSAGE_USAGE = COMMAND_WORD + " (alias: " + SHORTENED_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"
+ "Example: " + COMMAND_WORD + " 1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
public class EditPersonCommand extends Command {

public static final String COMMAND_WORD = "editPerson";
public static final String SHORTENED_COMMAND_WORD = "ep";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the person identified "
public static final String MESSAGE_USAGE = COMMAND_WORD + " (alias: " + SHORTENED_COMMAND_WORD + ")"
+ ": Edits the details of the person identified "
+ "by the index number used in the displayed person list. "
+ "Existing values will be overwritten by the input values.\n"
+ "Parameters: INDEX (must be a positive integer) "
Expand Down Expand Up @@ -139,7 +141,8 @@ public static class EditPersonDescriptor {
private Address address;
private Set<Tag> tags;

public EditPersonDescriptor() {}
public EditPersonDescriptor() {
}

/**
* Copy constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
public class EditTaskCommand extends Command {

public static final String COMMAND_WORD = "editTask";
public static final String SHORTENED_COMMAND_WORD = "et";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the task identified "
public static final String MESSAGE_USAGE = COMMAND_WORD + " (alias: " + SHORTENED_COMMAND_WORD + ")"
+ ": Edits the details of the task identified "
+ "by the index number used in the displayed task list. "
+ "Existing values will be overwritten by the input values.\n"
+ "Parameters: INDEX (must be a positive integer) "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public class ExitCommand extends Command {

public static final String COMMAND_WORD = "exit";
public static final String SHORTENED_COMMAND_WORD = "e";

public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting Address Book as requested ...";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
public class FindDoneCommand extends Command {

public static final String COMMAND_WORD = "findDone";
public static final String SHORTENED_COMMAND_WORD = "fd";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all tasks whose status is marked as "
public static final String MESSAGE_USAGE = COMMAND_WORD + " (alias: " + SHORTENED_COMMAND_WORD + ")"
+ ": Finds all tasks whose status is marked as "
+ "done and displays them as a list with index numbers.\n"
+ "Example: " + COMMAND_WORD;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
public class FindNotDoneCommand extends Command {

public static final String COMMAND_WORD = "findNotDone";
public static final String SHORTENED_COMMAND_WORD = "fnd";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all tasks whose status is marked as "
public static final String MESSAGE_USAGE = COMMAND_WORD + " (alias: " + SHORTENED_COMMAND_WORD + ")"
+ ": Finds all tasks whose status is marked as "
+ "not done and displays them as a list with index numbers.\n"
+ "Example: " + COMMAND_WORD;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
public class FindPersonCommand extends Command {

public static final String COMMAND_WORD = "findPerson";
public static final String SHORTENED_COMMAND_WORD = "fp";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of "
public static final String MESSAGE_USAGE = COMMAND_WORD + " (alias: " + SHORTENED_COMMAND_WORD + ")"
+ ": Finds all persons whose names contain any of "
+ "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n"
+ "Parameters: KEYWORD [MORE_KEYWORDS]...\n"
+ "Example: " + COMMAND_WORD + " alice bob charlie";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
public class FindTagCommand extends Command {

public static final String COMMAND_WORD = "findTag";
public static final String SHORTENED_COMMAND_WORD = "ftag";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons and tasks whose tag contain any of "
public static final String MESSAGE_USAGE = COMMAND_WORD + " (alias: " + SHORTENED_COMMAND_WORD + ")"
+ ": Finds all persons and tasks whose tag contain any of "
+ "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n"
+ "Parameters: KEYWORD [MORE_KEYWORDS]...\n"
+ "Example: " + COMMAND_WORD + " agenda";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
public class FindTaskCommand extends Command {

public static final String COMMAND_WORD = "findTask";
public static final String SHORTENED_COMMAND_WORD = "ft";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all tasks whose title or note contain any of "
public static final String MESSAGE_USAGE = COMMAND_WORD + " (alias: " + SHORTENED_COMMAND_WORD + ")"
+ ": Finds all tasks whose title or note contain any of "
+ "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n"
+ "Parameters: KEYWORD [MORE_KEYWORDS]...\n"
+ "Example: " + COMMAND_WORD + " agenda budget";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public class HelpCommand extends Command {

public static final String COMMAND_WORD = "help";
public static final String SHORTENED_COMMAND_WORD = "h";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Shows program usage instructions.\n"
+ "Example: " + COMMAND_WORD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
public class ListPersonCommand extends Command {

public static final String COMMAND_WORD = "listPerson";
public static final String SHORTENED_COMMAND_WORD = "lp";

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


@Override
public CommandResult execute(Model model) {
requireNonNull(model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
* Lists all tags in CoordiMate to the user.
*/
public class ListTagCommand extends Command {

public static final String COMMAND_WORD = "listTag";
public static final String SHORTENED_COMMAND_WORD = "ltag";

public static final String MESSAGE_NO_TAGS_FOUND = "No tags found!";
public static final String MESSAGE_SUCCESS = "Listed all tags: \n%s\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
* Lists all tasks in CoordiMate to the user.
*/
public class ListTaskCommand extends Command {

public static final String COMMAND_WORD = "listTask";
public static final String SHORTENED_COMMAND_WORD = "lt";

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


@Override
public CommandResult execute(Model model) {
requireNonNull(model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
public class MarkTaskCommand extends Command {

public static final String COMMAND_WORD = "markTask";
public static final String SHORTENED_COMMAND_WORD = "mt";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Mark status as done for the task specified "
public static final String MESSAGE_USAGE = COMMAND_WORD + " (alias: " + SHORTENED_COMMAND_WORD + ")"
+ ": Mark status as done for the task specified "
+ "by the index number used in the displayed task list.\n"
+ "Parameters: INDEX (must be a positive integer)\n"
+ "Example: " + COMMAND_WORD + " 1 ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
public class UnmarkTaskCommand extends Command {

public static final String COMMAND_WORD = "unmarkTask";
public static final String SHORTENED_COMMAND_WORD = "ut";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Mark status as not done for the task specified "
public static final String MESSAGE_USAGE = COMMAND_WORD + " (alias: " + SHORTENED_COMMAND_WORD + ")"
+ ": Mark status as not done for the task specified "
+ "by the index number used in the displayed task list.\n"
+ "Parameters: INDEX (must be a positive integer)\n"
+ "Example: " + COMMAND_WORD + " 1 ";
Expand Down Expand Up @@ -79,4 +81,3 @@ public String toString() {
.toString();
}
}

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

case AddPersonCommand.COMMAND_WORD:
// Fallthrough
case AddPersonCommand.SHORTENED_COMMAND_WORD:
return new AddPersonCommandParser().parse(arguments);

case EditPersonCommand.COMMAND_WORD:
// Fallthrough
case EditPersonCommand.SHORTENED_COMMAND_WORD:
return new EditPersonCommandParser().parse(arguments);

case DeletePersonCommand.COMMAND_WORD:
// Fallthrough
case DeletePersonCommand.SHORTENED_COMMAND_WORD:
return new DeletePersonCommandParser().parse(arguments);

case DeleteAllPersonCommand.COMMAND_WORD:
// Fallthrough
case DeleteAllPersonCommand.SHORTENED_COMMAND_WORD:
return new DeleteAllPersonCommand();

case FindPersonCommand.COMMAND_WORD:
// Fallthrough
case FindPersonCommand.SHORTENED_COMMAND_WORD:
return new FindPersonCommandParser().parse(arguments);

case ListPersonCommand.COMMAND_WORD:
// Fallthrough
case ListPersonCommand.SHORTENED_COMMAND_WORD:
return new ListPersonCommand();

case ListTaskCommand.COMMAND_WORD:
// Fallthrough
case ListTaskCommand.SHORTENED_COMMAND_WORD:
return new ListTaskCommand();

case DeleteTaskCommand.COMMAND_WORD:
// Fallthrough
case DeleteTaskCommand.SHORTENED_COMMAND_WORD:
return new DeleteTaskCommandParser().parse(arguments);

case MarkTaskCommand.COMMAND_WORD:
// Fallthrough
case MarkTaskCommand.SHORTENED_COMMAND_WORD:
return new MarkTaskCommandParser().parse(arguments);

case UnmarkTaskCommand.COMMAND_WORD:
// Fallthrough
case UnmarkTaskCommand.SHORTENED_COMMAND_WORD:
return new UnmarkTaskCommandParser().parse(arguments);

case AddTaskCommand.COMMAND_WORD:
// Fallthrough
case AddTaskCommand.SHORTENED_COMMAND_WORD:
return new AddTaskCommandParser().parse(arguments);

case EditTaskCommand.COMMAND_WORD:
// Fallthrough
case EditTaskCommand.SHORTENED_COMMAND_WORD:
return new EditTaskCommandParser().parse(arguments);

case FindTaskCommand.COMMAND_WORD:
// Fallthrough
case FindTaskCommand.SHORTENED_COMMAND_WORD:
return new FindTaskCommandParser().parse(arguments);

case FindDoneCommand.COMMAND_WORD:
// Fallthrough
case FindDoneCommand.SHORTENED_COMMAND_WORD:
return new FindDoneCommand();

case FindNotDoneCommand.COMMAND_WORD:
// Fallthrough
case FindNotDoneCommand.SHORTENED_COMMAND_WORD:
return new FindNotDoneCommand();

case DeleteAllTaskCommand.COMMAND_WORD:
// Fallthrough
case DeleteAllTaskCommand.SHORTENED_COMMAND_WORD:
return new DeleteAllTaskCommand();

case FindTagCommand.COMMAND_WORD:
// Fallthrough
case FindTagCommand.SHORTENED_COMMAND_WORD:
return new FindTagCommandParser().parse(arguments);

case ListTagCommand.COMMAND_WORD:
// Fallthrough
case ListTagCommand.SHORTENED_COMMAND_WORD:
return new ListTagCommand();

case ExitCommand.COMMAND_WORD:
// Fallthrough
case ExitCommand.SHORTENED_COMMAND_WORD:
return new ExitCommand();

case HelpCommand.COMMAND_WORD:
// Fallthrough
case HelpCommand.SHORTENED_COMMAND_WORD:
return new HelpCommand();

default:
Expand Down
Loading

0 comments on commit d5a3d4a

Please sign in to comment.