forked from nus-cs2103-AY2122S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve command parsing and error handling
- Loading branch information
Showing
60 changed files
with
975 additions
and
586 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,12 @@ | |
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; | ||
import static seedu.address.logic.parser.CommandArgument.optionalMultiple; | ||
import static seedu.address.logic.parser.CommandArgument.requiredSingle; | ||
|
||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.logic.parser.CommandArgument; | ||
import seedu.address.logic.parser.CommandSpecification; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.person.Person; | ||
|
||
|
@@ -18,20 +22,22 @@ public class AddCommand extends Command { | |
|
||
public static final String COMMAND_WORD = "add"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. " | ||
+ "Parameters: " | ||
+ PREFIX_NAME + "NAME " | ||
+ PREFIX_PHONE + "PHONE " | ||
+ PREFIX_EMAIL + "EMAIL " | ||
+ PREFIX_ADDRESS + "ADDRESS " | ||
+ "[" + PREFIX_TAG + "TAG]...\n" | ||
+ "Example: " + COMMAND_WORD + " " | ||
+ PREFIX_NAME + "John Doe " | ||
+ PREFIX_PHONE + "98765432 " | ||
+ PREFIX_EMAIL + "[email protected] " | ||
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " | ||
+ PREFIX_TAG + "friends " | ||
+ PREFIX_TAG + "owesMoney"; | ||
public static final CommandSpecification COMMAND_SPECS = new CommandSpecification( | ||
COMMAND_WORD, | ||
"Adds a person to the address book.", | ||
requiredSingle(PREFIX_NAME, "name"), | ||
requiredSingle(PREFIX_PHONE, "phone"), | ||
requiredSingle(PREFIX_EMAIL, "email"), | ||
requiredSingle(PREFIX_ADDRESS, "address"), | ||
optionalMultiple(PREFIX_TAG, "tag") | ||
).withExample( | ||
CommandArgument.filled(PREFIX_NAME, "John Doe"), | ||
CommandArgument.filled(PREFIX_PHONE, "98765432"), | ||
CommandArgument.filled(PREFIX_EMAIL, "[email protected]"), | ||
CommandArgument.filled(PREFIX_ADDRESS, "311, Clementi Ave 2, #02-25"), | ||
CommandArgument.filled(PREFIX_TAG, "friends"), | ||
CommandArgument.filled(PREFIX_TAG, "owesMoney") | ||
); | ||
|
||
public static final String MESSAGE_SUCCESS = "New person added: %1$s"; | ||
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book"; | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,12 @@ | |
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PREAMBLE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; | ||
import static seedu.address.logic.parser.CommandArgument.filled; | ||
import static seedu.address.logic.parser.CommandArgument.optionalMultiple; | ||
import static seedu.address.logic.parser.CommandArgument.optionalSingle; | ||
import static seedu.address.logic.parser.CommandArgument.requiredSingle; | ||
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; | ||
|
||
import java.util.Collections; | ||
|
@@ -18,6 +23,7 @@ | |
import seedu.address.commons.core.index.Index; | ||
import seedu.address.commons.util.CollectionUtil; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.logic.parser.CommandSpecification; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.person.Address; | ||
import seedu.address.model.person.Email; | ||
|
@@ -32,19 +38,22 @@ | |
public class EditCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "edit"; | ||
|
||
public static final String MESSAGE_USAGE = | ||
COMMAND_WORD + ": Edits the details of the person identified " | ||
public static final CommandSpecification COMMAND_SPECS = new CommandSpecification( | ||
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) " | ||
+ "[" + PREFIX_NAME + "NAME] " | ||
+ "[" + PREFIX_PHONE + "PHONE] " | ||
+ "[" + PREFIX_EMAIL + "EMAIL] " | ||
+ "[" + PREFIX_ADDRESS + "ADDRESS] " | ||
+ "[" + PREFIX_TAG + "TAG]...\n" | ||
+ "Example: " + COMMAND_WORD + " 1 " + PREFIX_PHONE | ||
+ "91234567 " + PREFIX_EMAIL + "[email protected]"; | ||
+ "Existing values will be overwritten by the input values.", | ||
requiredSingle(PREFIX_PREAMBLE, "index"), | ||
optionalSingle(PREFIX_NAME, "name"), | ||
optionalSingle(PREFIX_PHONE, "phone"), | ||
optionalSingle(PREFIX_EMAIL, "email"), | ||
optionalSingle(PREFIX_ADDRESS, "address"), | ||
optionalMultiple(PREFIX_TAG, "tag") | ||
).withExample( | ||
filled(PREFIX_PREAMBLE, "1"), | ||
filled(PREFIX_PHONE, "91234567"), | ||
filled(PREFIX_EMAIL, "[email protected]") | ||
); | ||
|
||
public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edited Person: %1$s"; | ||
public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided."; | ||
|
@@ -56,7 +65,7 @@ public class EditCommand extends Command { | |
private Person editedPerson; | ||
|
||
/** | ||
* @param index index of the person in the filtered person list to edit | ||
* @param index index of the person in the filtered person list to edit | ||
* @param editPersonDescriptor details to edit the person with | ||
*/ | ||
public EditCommand(Index index, EditPersonDescriptor editPersonDescriptor) { | ||
|
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
Oops, something went wrong.