Skip to content

Commit

Permalink
Merge pull request #138 from Bandov/case-sensitivity-update
Browse files Browse the repository at this point in the history
made all commands non case sensitive
  • Loading branch information
Bandov authored Apr 1, 2024
2 parents 7ba5251 + 8291188 commit 7692001
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
*/
public class AddAttributeCommand extends Command {

public static final String COMMAND_WORD = "addAttribute";
public static final String COMMAND_WORD = "addattribute";
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds attributes to a person in the address book. "
+ "\n"
+ "Command format: " + COMMAND_WORD + " UUID /attributeName1 attributeValue1 "
+ "/attributeName2 attributeValue2 ...\n"
+ "Example: " + COMMAND_WORD + " /4000 /Name John Doe /Phone 12345678";
public static final String COMMAND_WORD_SHORT = "aa";
private final String uuid;
private final Map<String, String> attributes;

Expand Down
2 changes: 2 additions & 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,8 @@ public class AddCommand extends Command {

public static final String COMMAND_WORD = "add";

public static final String COMMAND_WORD_SHORT = "a";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. "
+ "Optional Parameters: /YourAttributeName YourAttributeValue\n"
+ "Predefined parameters: "
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/seedu/address/logic/commands/ClearCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
*/
public class ClearCommand extends Command {

public static final String COMMAND_WORD = "clear";
public static final String COMMAND_WORD = "deleteallpersons";

public static final String COMMAND_WORD_SHORT = "dap";
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 @@ -15,7 +15,8 @@
*/
public class DeleteAttributeCommand extends Command {

public static final String COMMAND_WORD = "deleteAttribute";
public static final String COMMAND_WORD = "deleteattribute";
public static final String COMMAND_WORD_SHORT = "da";
private static final String MESSAGE_SUCCESS = "Attribute deleted from person: %1$s";
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Deletes attributes from a person in the address book. "
+ "\n"
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/seedu/address/logic/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class DeleteCommand extends Command {

public static final String COMMAND_WORD = "delete";

public static final String COMMAND_WORD_SHORT = "d";

public static final String MESSAGE_USAGE = 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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
*/
public class EditAttributeCommand extends Command {

public static final String COMMAND_WORD = "editAttribute";
public static final String COMMAND_WORD = "editattribute";
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits attributes of a person in the address book. "
+ "\n"
+ "Command format: " + COMMAND_WORD + " /UUID /attributeName1 attributeValue1 "
+ "/attributeName2 attributeValue2 ...\n"
+ "Example: " + COMMAND_WORD + " /4000 /Name John Doe /Phone 12345678";
public static final String COMMAND_WORD_SHORT = "ea";
private final String uuid;
private final Map<String, String> attributesToEdit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class ExitCommand extends Command {
public static final String COMMAND_WORD = "exit";

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

@Override
public CommandResult execute(Model model) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/seedu/address/logic/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class FindCommand extends Command {

public static final String COMMAND_WORD = "find";

public static final String COMMAND_WORD_SHORT = "f";

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"
+ "Parameters: KEYWORD [MORE_KEYWORDS]...\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class HelpCommand extends Command {
+ "Example: " + COMMAND_WORD;

public static final String SHOWING_HELP_MESSAGE = "Opened help window.";
public static final String COMMAND_WORD_SHORT = "h";

@Override
public CommandResult execute(Model model) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class ListCommand extends Command {
public static final String COMMAND_WORD = "list";

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


@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Command parse(String userInput) throws ParseException {
String[] commandParts = userInput.split(" ", 3);

// Validate command structure
if (commandParts.length < 3 || !"addAttribute".equalsIgnoreCase(commandParts[0])) {
if (commandParts.length < 3) {
throw new ParseException(AddAttributeCommand.MESSAGE_USAGE);
}

Expand Down
18 changes: 17 additions & 1 deletion src/main/java/seedu/address/logic/parser/AddressBookParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Command parseCommand(String userInput) throws ParseException, CommandExce
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, HelpCommand.MESSAGE_USAGE));
}

final String commandWord = matcher.group("commandWord");
final String commandWord = matcher.group("commandWord").toLowerCase();
final String arguments = matcher.group("arguments");

// Note to developers: Change the log level in config.json to enable lower level (i.e., FINE, FINER and lower)
Expand All @@ -71,51 +71,67 @@ public Command parseCommand(String userInput) throws ParseException, CommandExce
switch (commandWord) {

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

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

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

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

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

case ExitCommand.COMMAND_WORD:
case ExitCommand.COMMAND_WORD_SHORT:
return new ExitCommand();

case HelpCommand.COMMAND_WORD:
case HelpCommand.COMMAND_WORD_SHORT:
return new HelpCommand();

case AddRelationshipCommand.COMMAND_WORD:
case AddRelationshipCommand.COMMAND_WORD_SHORT:
return new AddRelationshipCommandParser().parse(arguments.trim());

case DeleteRelationshipCommand.COMMAND_WORD:
case DeleteRelationshipCommand.COMMAND_WORD_SHORT:
return new DeleteRelationshipCommandParser().parse(arguments.trim());

case EditRelationshipCommand.COMMAND_WORD:
case EditRelationshipCommand.COMMAND_WORD_SHORT:
return new EditRelationshipCommandParser().parse(arguments.trim());

case ListRelationshipTypesCommand.COMMAND_WORD:
case ListRelationshipTypesCommand.COMMAND_WORD_SHORT:
return new ListRelationshipTypesCommand();

case AnySearchCommand.COMMAND_WORD:
case AnySearchCommand.COMMAND_WORD_SHORT:
return new AnySearchCommandParser().parse(arguments.trim());

case FamilySearchCommand.COMMAND_WORD:
case FamilySearchCommand.COMMAND_WORD_SHORT:
return new FamilySearchCommandParser().parse(arguments.trim());

case DeleteAttributeCommand.COMMAND_WORD:
case DeleteAttributeCommand.COMMAND_WORD_SHORT:
return new DeleteAttributeCommandParser().parse(arguments.trim());

case AddAttributeCommand.COMMAND_WORD:
case AddAttributeCommand.COMMAND_WORD_SHORT:
return new AddAttributeParser().parse(userInput);

case EditAttributeCommand.COMMAND_WORD:
case EditAttributeCommand.COMMAND_WORD_SHORT:
return new EditCommandParser().parse(userInput.trim());

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public EditAttributeCommand parse(String args) throws ParseException {
String[] parts = args.split(" ", 3);

// Validate command structure
if (parts.length < 3 || !"editAttribute".equalsIgnoreCase(parts[0])) {
if (parts.length < 3) {
throw new ParseException(EditAttributeCommand.MESSAGE_USAGE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
* It supports adding relationships with and without roles.
*/
public class AddRelationshipCommand extends Command {
public static final String COMMAND_WORD = "addRelation";
public static final String COMMAND_WORD = "addrelation";
public static final String MESSAGE_ADD_RELATIONSHIP_SUCCESS = "Add success";
public static final String COMMAND_WORD_SHORT = "ar";
private String originUuid;
private String targetUuid;
private String relationshipDescriptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
*/
public class AnySearchCommand extends Command {

public static final String COMMAND_WORD = "anySearch";
public static final String COMMAND_WORD = "anysearch";
public static final String COMMAND_WORD_SHORT = "as";

private String originUuid;
private String targetUuid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
* Represents a command to delete a relationship between two persons.
*/
public class DeleteRelationshipCommand extends Command {
public static final String COMMAND_WORD = "deleteRelation";
public static final String COMMAND_WORD = "deleterelation";
public static final String MESSAGE_DELETE_RELATIONSHIP_SUCCESS = "Delete successful";
public static final String COMMAND_WORD_SHORT = "dr";
private String originUuid = "0000";
private String targetUuid = "0000";
private String relationshipDescriptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
* It supports adding relationships with and without roles.
*/
public class EditRelationshipCommand extends Command {
public static final String COMMAND_WORD = "editRelation";
public static final String COMMAND_WORD = "editrelation";
public static final String MESSAGE_EDIT_RELATIONSHIP_SUCCESS = "Edit successful";
public static final String COMMAND_WORD_SHORT = "er";
private String originUuid;
private String targetUuid;
private String oldRelationshipDescriptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
*/
public class FamilySearchCommand extends Command {

public static final String COMMAND_WORD = "familySearch";
public static final String COMMAND_WORD = "familysearch";
public static final String COMMAND_WORD_SHORT = "fs";

private String originUuid;
private String targetUuid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
* Lists all the relationship types in the address book.
*/
public class ListRelationshipTypesCommand extends Command {
public static final String COMMAND_WORD = "listRelations";
public static final String COMMAND_WORD = "listrelations";
public static final String COMMAND_WORD_SHORT = "lr";

/**
* Executes the command to list all the relationship types in the address book.
Expand Down

0 comments on commit 7692001

Please sign in to comment.