From 15b5b45c5c22a4d2709e7c88fb60d62174c5abd2 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 5 Nov 2024 14:45:37 +0800 Subject: [PATCH 1/3] Refine output message for AddCommand Reorganise the output message when there is a invalid add command. --- .../seedu/address/logic/commands/AddCommand.java | 14 ++++++++------ .../address/logic/parser/AddCommandParser.java | 5 +++-- .../logic/parser/AddCommandParserTest.java | 15 ++++++++------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 06dee60903a..b95990d5bc3 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -23,14 +23,14 @@ public class AddCommand extends Command { public static final String SHORT_COMMAND_WORD = "a"; - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to ClientHub.\n" + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a client to ClientHub.\n" + "Parameters: " + PREFIX_NAME + "NAME " + PREFIX_PHONE + "PHONE " + PREFIX_EMAIL + "EMAIL " + PREFIX_ADDRESS + "ADDRESS " + PREFIX_DESCRIPTION + "DESCRIPTION " - + PREFIX_CLIENT_TYPE + "CLIENT_TYPE...\n" + + PREFIX_CLIENT_TYPE + "CLIENT_TYPE\n" + "Example: " + COMMAND_WORD + " " + PREFIX_NAME + "John Doe " + PREFIX_PHONE + "98765432 " @@ -38,11 +38,13 @@ public class AddCommand extends Command { + PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " + PREFIX_CLIENT_TYPE + "Plan A " + PREFIX_CLIENT_TYPE + "Plan B " - + PREFIX_DESCRIPTION + "Likes to eat a lot "; + + PREFIX_DESCRIPTION + "Likes to eat a lot \n" + + "Additional Info:\n" + + "- Can add multiple c/ to add multiple CLIENT_TYPE\n"; - public static final String MESSAGE_SUCCESS = "New person added: %1$s"; - public static final String MESSAGE_DUPLICATE_PERSON = "This name already exists in the address book. If the " - + "newly added person has the same name, Please add use () to add more information after the name " + public static final String MESSAGE_SUCCESS = "New client added: %1$s"; + public static final String MESSAGE_DUPLICATE_PERSON = "This name already exists in Client Hub. If the " + + "newly added client has the same name, Please add use () to add more information after the name " + "to differentiate the names."; private final Person toAdd; diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 7f56a243264..f2712f17288 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -28,8 +28,9 @@ */ public class AddCommandParser implements Parser { - private static final String MESSAGE_MISSING_FIELD = "The following field is missing: %s"; - private static final String MESSAGE_MULTIPLE_MISSING_FIELDS = "The following fields are missing: %s"; + private static final String MESSAGE_MISSING_FIELD = "The following field for add command is missing: %s"; + private static final String MESSAGE_MULTIPLE_MISSING_FIELDS = + "The following fields for add command are missing: %s"; // Map to store prefix to field description mapping private static final HashMap FIELD_DESCRIPTIONS = new HashMap<>(); diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index 7065175d181..4fec4f49c5e 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -153,40 +153,41 @@ public void parse_repeatedNonClientTypeValue_failure() { @Test public void parse_compulsoryFieldMissing_failure() { + // missing name prefix assertParseFailure(parser, PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + CLIENT_TYPE_DESC_A + DESCRIPTION_DESC_A + VALID_NAME_BOB, - "The following field is missing: n/NAME"); + "The following field for add command is missing: n/NAME"); // missing phone prefix assertParseFailure(parser, NAME_DESC_BOB + VALID_PHONE_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + CLIENT_TYPE_DESC_A + DESCRIPTION_DESC_A, - "The following field is missing: p/PHONE"); + "The following field for add command is missing: p/PHONE"); // missing email prefix assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + VALID_EMAIL_BOB + ADDRESS_DESC_BOB + CLIENT_TYPE_DESC_A + DESCRIPTION_DESC_A, - "The following field is missing: e/EMAIL"); + "The following field for add command is missing: e/EMAIL"); // missing address prefix assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + VALID_ADDRESS_BOB + CLIENT_TYPE_DESC_A + DESCRIPTION_DESC_A, - "The following field is missing: a/ADDRESS"); + "The following field for add command is missing: a/ADDRESS"); // missing description prefix assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + CLIENT_TYPE_DESC_A + VALID_DESCRIPTION_A, - "The following field is missing: d/DESCRIPTION"); + "The following field for add command is missing: d/DESCRIPTION"); // missing client type prefix assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + VALID_CLIENT_TYPE_A + DESCRIPTION_DESC_A, - "The following field is missing: c/CLIENT_TYPE"); + "The following field for add command is missing: c/CLIENT_TYPE"); // all prefixes missing assertParseFailure(parser, VALID_NAME_BOB + VALID_PHONE_BOB + VALID_EMAIL_BOB + VALID_ADDRESS_BOB + VALID_CLIENT_TYPE_A + VALID_DESCRIPTION_A, - "The following fields are missing: n/NAME a/ADDRESS p/PHONE " + "The following fields for add command are missing: n/NAME a/ADDRESS p/PHONE " + "e/EMAIL c/CLIENT_TYPE d/DESCRIPTION"); } From 202516e54cac7c56a6f80a2bcdff3dafd79ca3a3 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 5 Nov 2024 15:16:03 +0800 Subject: [PATCH 2/3] Refine output message for DeleteCommand Make the output message neater. --- .../address/logic/commands/DeleteCommand.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index 4ef4bdeb6c7..03aae6dfd7e 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -19,12 +19,14 @@ public class DeleteCommand extends Command { public static final String SHORT_COMMAND_WORD = "d"; public static final String MESSAGE_USAGE = COMMAND_WORD - + ": Deletes the person identified by their name in the displayed person list.\n" - + "Parameters: Name (String & must be non-empty)\n" - + "Example: " + COMMAND_WORD + " John Doe " + " " + " or " + " " - + " Example: " + SHORT_COMMAND_WORD + " John Doe \n" - + "To delete a person with a common name, please provide fullname or use /" - + " to indicate the end of the name eg Jon snow/ \n"; + + ": Deletes the client identified by their name in the displayed client list.\n" + + "Parameters: NAME (String & must be non-empty)\n" + + "Example: " + COMMAND_WORD + " John Doe " + + " or " + " " + + SHORT_COMMAND_WORD + " John Doe \n" + + "Additional Info: \n" + + "- To delete a client with a common name, please provide fullname or\n" + + "use / to indicate the end of the name eg Jon snow/"; public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Person: %1$s"; From 24dc0ed40ee88025a48bda040bf9764ac9ebb840 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 5 Nov 2024 16:25:05 +0800 Subject: [PATCH 3/3] Refine output messages for find command Refine the output messages for all the Find commands including the shortcut commands to make the format more standardised. --- .../logic/commands/FindAddressCommand.java | 16 ++++++++++++---- .../logic/commands/FindClientTypeCommand.java | 17 ++++++++++++++--- .../address/logic/commands/FindCommand.java | 13 ++++++++----- .../logic/commands/FindNameCommand.java | 19 +++++++++++++------ .../logic/commands/FindPhoneCommand.java | 16 ++++++++++++---- 5 files changed, 59 insertions(+), 22 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/FindAddressCommand.java b/src/main/java/seedu/address/logic/commands/FindAddressCommand.java index ba4908aed2c..00267e27174 100644 --- a/src/main/java/seedu/address/logic/commands/FindAddressCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindAddressCommand.java @@ -1,6 +1,7 @@ package seedu.address.logic.commands; import static java.util.Objects.requireNonNull; +import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages; @@ -15,10 +16,17 @@ public class FindAddressCommand extends Command { public static final String COMMAND_WORD = "fa"; - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose address 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 + " tampines"; + public static final String MESSAGE_USAGE = FindCommand.COMMAND_WORD + " " + PREFIX_ADDRESS + + " or " + COMMAND_WORD + + ": Finds all clients whose address contain any of " + + "the specified ADDRESS and displays them as a list with index numbers.\n" + + "Parameters: ADDRESS\n" + + "Example:\n" + + "- " + COMMAND_WORD + " tampines\n" + + "- " + FindCommand.COMMAND_WORD + " " + PREFIX_ADDRESS + "tampines\n" + + "Additional Info: \n" + + "- ADDRESS is case-insensitive.\n" + + "- ADDRESS should not be empty."; private final AddressContainsKeywordsPredicate predicate; diff --git a/src/main/java/seedu/address/logic/commands/FindClientTypeCommand.java b/src/main/java/seedu/address/logic/commands/FindClientTypeCommand.java index 409b28b2a16..8bfb3d11450 100644 --- a/src/main/java/seedu/address/logic/commands/FindClientTypeCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindClientTypeCommand.java @@ -1,6 +1,7 @@ package seedu.address.logic.commands; import static java.util.Objects.requireNonNull; +import static seedu.address.logic.parser.CliSyntax.PREFIX_CLIENT_TYPE; import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages; @@ -16,10 +17,20 @@ public class FindClientTypeCommand extends Command { public static final String COMMAND_WORD = "fc"; - public static final String MESSAGE_USAGE = 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" + public static final String MESSAGE_USAGE = FindCommand.COMMAND_WORD + " " + PREFIX_CLIENT_TYPE + + " or " + COMMAND_WORD + + ": Finds all clients whose names contain any of " + + "the specified CLIENT_TYPE and displays them as a list with index numbers.\n" + "Parameters: CLIENT_TYPE [MORE_CLIENT_TYPES]...\n" - + "Example: " + COMMAND_WORD + "Investment Plan 1"; + + "Examples: \n" + + COMMAND_WORD + " Investment Plan\n" + + COMMAND_WORD + " Investment Plan Healthcare\n" + + FindCommand.COMMAND_WORD + " " + PREFIX_CLIENT_TYPE + "Investment Plan\n" + + FindCommand.COMMAND_WORD + " " + PREFIX_CLIENT_TYPE + "Investment Plan Healthcare\n" + + "Additional Info: \n" + + "- CLIENT_TYPE is case-insensitive.\n" + + "- CLIENT_TYPE should not be empty.\n" + + "- Can specify multiple CLIENT_TYPE to have a more specific find."; private final ClientTypeContainsKeywordsPredicate predicate; diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index cb3c1abbea0..56e5d258dd2 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -18,11 +18,14 @@ public class FindCommand extends Command { public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds persons whose name, phone number, " + "address or client type contain any of " + "all specified keywords (case-insensitive) and displays them as a list with index numbers.\n" - + "Parameters: KEYWORD [MORE_KEYWORDS]...\n" - + "Example: " + COMMAND_WORD + " alice wong" - + "Example: " + COMMAND_WORD + " p/91234567" - + "Example: " + COMMAND_WORD + " a/123, Jurong West Ave 6" - + "Example: " + COMMAND_WORD + " c/Investment Plan 1"; + + "Parameters: n/NAME or p/PHONE_NUMBER, or a/ADDRESS or c/CLIENT_TYPE\n" + + "Example:\n" + + "- " + COMMAND_WORD + " alice wong\n" + + "- " + COMMAND_WORD + " p/91234567\n" + + "- " + COMMAND_WORD + " a/123, Jurong West Ave 6\n" + + "- " + COMMAND_WORD + " c/Investment Plan 1\n" + + "Additional Info:\n" + + "- The command can only take in one prefix at any point of time. (find n/NAME a/Address is invalid)\n"; private final NameContainsKeywordsPredicate predicate; diff --git a/src/main/java/seedu/address/logic/commands/FindNameCommand.java b/src/main/java/seedu/address/logic/commands/FindNameCommand.java index dbfbfee6262..c781d24ba42 100644 --- a/src/main/java/seedu/address/logic/commands/FindNameCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindNameCommand.java @@ -1,6 +1,7 @@ package seedu.address.logic.commands; import static java.util.Objects.requireNonNull; +import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages; @@ -15,12 +16,18 @@ public class FindNameCommand extends Command { public static final String COMMAND_WORD = "fn"; - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain all of " - + "the prefix of the specified keywords and displays them as a list with index numbers. The keywards are " - + "case-insensitive. They should contain letters,spaces and parenthesis only. They cannot be empty or have " - + "only spaces\n" - + "Parameters: KEYWORDS\n" - + "Example: " + COMMAND_WORD + "alice"; + public static final String MESSAGE_USAGE = FindCommand.COMMAND_WORD + " " + PREFIX_NAME + + " or " + COMMAND_WORD + + ": Finds all persons whose names contain all of " + + "the prefix of the specified NAME and displays them as a list with index numbers.\n" + + "Parameters: NAME (String & must be non-empty)\n" + + "Example:\n" + + "- " + COMMAND_WORD + " Alice\n" + + "- " + FindCommand.COMMAND_WORD + " " + PREFIX_NAME + "Alice\n" + + "Additional Info: \n" + + "- NAME is case-insensitive.\n" + + "- It should contain letters, spaces, parenthesis or slashes only.\n" + + "- They cannot be empty or have only spaces."; private final NameContainsKeywordsPredicate predicate; diff --git a/src/main/java/seedu/address/logic/commands/FindPhoneCommand.java b/src/main/java/seedu/address/logic/commands/FindPhoneCommand.java index b79c69031b5..7dd1c126d3e 100644 --- a/src/main/java/seedu/address/logic/commands/FindPhoneCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindPhoneCommand.java @@ -1,6 +1,7 @@ package seedu.address.logic.commands; import static java.util.Objects.requireNonNull; +import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages; @@ -15,10 +16,17 @@ public class FindPhoneCommand extends Command { public static final String COMMAND_WORD = "fp"; - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose phone number begins with " - + "the specified keywords (integers only with no spacing) and displays them as a list with index numbers.\n" - + "Parameters: integers \n" - + "Example: " + COMMAND_WORD + " 91234567"; + public static final String MESSAGE_USAGE = FindCommand.COMMAND_WORD + " " + PREFIX_PHONE + + " or " + COMMAND_WORD + + ": Finds all clients whose phone number begins with " + + "the specified PHONE_NUMBER and displays them as a list with index numbers.\n" + + "Parameters: PHONE_NUMBER (Contains only 8 digits)\n" + + "Example:\n" + + "- " + COMMAND_WORD + " 91234567\n" + + "- " + FindCommand.COMMAND_WORD + " " + PREFIX_PHONE + "91234567\n" + + "Additional Info: \n" + + "- PHONE_NUMBER is a sequence of integers with no spacing."; + private final PhoneBeginsWithKeywordPredicate predicate;