diff --git a/src/main/java/seedu/address/logic/commands/ChangeDirectoryCommand.java b/src/main/java/seedu/address/logic/commands/ChangeDirectoryCommand.java index 9336cbb8ddb..369659089ef 100644 --- a/src/main/java/seedu/address/logic/commands/ChangeDirectoryCommand.java +++ b/src/main/java/seedu/address/logic/commands/ChangeDirectoryCommand.java @@ -18,8 +18,10 @@ public class ChangeDirectoryCommand extends Command { public static final String MESSAGE_PATH_NOT_FOUND = "Path does not exist in ProfBook."; public static final String MESSAGE_USAGE = COMMAND_WORD + " [destination path]"; + public static final ChangeDirectoryCommand HELP_MESSAGE = new ChangeDirectoryCommand(); private final AbsolutePath dest; + private final boolean isHelp; /** * Constructs a {@code MoveStudentToGroupCommand} with the specified source and destination paths. @@ -30,6 +32,12 @@ public class ChangeDirectoryCommand extends Command { public ChangeDirectoryCommand(AbsolutePath dest) { requireAllNonNull(dest); this.dest = dest; + this.isHelp = false; + } + + private ChangeDirectoryCommand() { + this.dest = null; + isHelp = true; } /** @@ -41,6 +49,10 @@ public ChangeDirectoryCommand(AbsolutePath dest) { */ @Override public CommandResult execute(Model model) throws CommandException { + if (isHelp) { + return new CommandResult(MESSAGE_USAGE); + } + if (!model.hasPath(dest)) { throw new CommandException(MESSAGE_PATH_NOT_FOUND); } diff --git a/src/main/java/seedu/address/logic/commands/CreateDeadlineCommand.java b/src/main/java/seedu/address/logic/commands/CreateDeadlineCommand.java index 142e4f69479..134ba92f3ec 100644 --- a/src/main/java/seedu/address/logic/commands/CreateDeadlineCommand.java +++ b/src/main/java/seedu/address/logic/commands/CreateDeadlineCommand.java @@ -51,10 +51,12 @@ public class CreateDeadlineCommand extends Command { public static final String MESSAGE_INVALID_PATH_FOR_ALL_STU = "AllStu flag is only allowed for root and group path"; public static final String MESSAGE_INVALID_PATH_FOR_ALL_GROUP = "AllGrp flag is only allowed for root path"; public static final String MESSAGE_ALL_CHILDREN_HAVE_TASK = "All %1$ss already have the task."; + public static final CreateDeadlineCommand HELP_MESSAGE = new CreateDeadlineCommand(); private final AbsolutePath path; private final Deadline deadline; - private Category category; + private final Category category; + private final boolean isHelp; /** * Creates an CreateDeadlineCommand to add the Deadline Task for a specified {@code Student} or {@code Group} @@ -65,6 +67,14 @@ public CreateDeadlineCommand(AbsolutePath path, Deadline deadline, Category cate this.path = path; this.deadline = deadline; this.category = category; + this.isHelp = false; + } + + private CreateDeadlineCommand() { + this.path = null; + this.deadline = null; + this.category = null; + this.isHelp = true; } /** @@ -75,6 +85,11 @@ public CreateDeadlineCommand(AbsolutePath path, Deadline deadline, Category cate */ @Override public CommandResult execute(Model model) throws CommandException { + + if (isHelp) { + return new CommandResult(MESSAGE_USAGE); + } + // Check path exists in ProfBook if (!model.hasPath(path)) { throw new CommandException(MESSAGE_PATH_NOT_FOUND); diff --git a/src/main/java/seedu/address/logic/commands/CreateGroupCommand.java b/src/main/java/seedu/address/logic/commands/CreateGroupCommand.java index 12518c7573b..3089c60a605 100644 --- a/src/main/java/seedu/address/logic/commands/CreateGroupCommand.java +++ b/src/main/java/seedu/address/logic/commands/CreateGroupCommand.java @@ -22,8 +22,11 @@ public class CreateGroupCommand extends Command { "GroupId %1$s has already been used by the group: %2$s"; public static final String MESSAGE_SUCCESS = "New group added: %1$s"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": group"; + public static final CreateGroupCommand HELP_MESSAGE = new CreateGroupCommand(); + private final AbsolutePath dest; private final Group group; + private final boolean isHelp; /** * Constructs a {@code CreateGroupCommand} with the specified absolute path and group details. @@ -35,6 +38,13 @@ public CreateGroupCommand(AbsolutePath dest, Group group) { requireAllNonNull(dest, group); this.dest = dest; this.group = group; + this.isHelp = false; + } + + private CreateGroupCommand() { + this.isHelp = true; + this.dest = null; + this.group = null; } /** @@ -48,6 +58,10 @@ public CreateGroupCommand(AbsolutePath dest, Group group) { public CommandResult execute(Model model) throws CommandException { requireNonNull(model); + if (isHelp) { + return new CommandResult(MESSAGE_USAGE); + } + ChildOperation rootOperation = model.rootChildOperation(); // Check duplicate group id diff --git a/src/main/java/seedu/address/logic/commands/CreateStudentCommand.java b/src/main/java/seedu/address/logic/commands/CreateStudentCommand.java index eaa3b2bb699..8bcef23f689 100644 --- a/src/main/java/seedu/address/logic/commands/CreateStudentCommand.java +++ b/src/main/java/seedu/address/logic/commands/CreateStudentCommand.java @@ -41,9 +41,11 @@ public class CreateStudentCommand extends Command { public static final String MESSAGE_INVALID_PATH = "Path provided should be a valid student path"; public static final String MESSAGE_UNSUPPORTED_PATH_OPERATION = "Path operation is not supported"; public static final String MESSAGE_GROUP_NOT_FOUND = "Group %1$s does not exist in ProfBook"; + public static final CreateStudentCommand HELP_MESSAGE = new CreateStudentCommand(); private final AbsolutePath path; private final Student student; + private final boolean isHelp; /** * Creates an CreateStudentCommand to add the specified {@code Student} @@ -52,6 +54,13 @@ public CreateStudentCommand(AbsolutePath path, Student student) { requireAllNonNull(path, student); this.path = path; this.student = student; + this.isHelp = false; + } + + private CreateStudentCommand() { + this.path = null; + this.student = null; + this.isHelp = true; } /** @@ -64,6 +73,10 @@ public CreateStudentCommand(AbsolutePath path, Student student) { public CommandResult execute(Model model) throws CommandException { requireNonNull(model); + if (isHelp) { + return new CommandResult(MESSAGE_USAGE); + } + if (!path.isStudentDirectory()) { throw new CommandException(MESSAGE_INVALID_PATH); } diff --git a/src/main/java/seedu/address/logic/commands/CreateTodoCommand.java b/src/main/java/seedu/address/logic/commands/CreateTodoCommand.java index ebfb3bfba4f..830366b7e73 100644 --- a/src/main/java/seedu/address/logic/commands/CreateTodoCommand.java +++ b/src/main/java/seedu/address/logic/commands/CreateTodoCommand.java @@ -45,10 +45,12 @@ public class CreateTodoCommand extends Command { public static final String MESSAGE_INVALID_PATH_FOR_ALL_GROUP = "AllGrp flag is only allowed for root path"; public static final String MESSAGE_ALL_CHILDREN_HAVE_TASK = "All %1$ss already have the task."; public static final String MESSAGE_USAGE = COMMAND_WORD + ": student"; + public static final CreateTodoCommand HELP_MESSAGE = new CreateTodoCommand(); private final AbsolutePath target; private final ToDo todo; - private Category category; + private final Category category; + private final boolean isHelp; /** * Constructs a {@code CreateTodoCommand} with the specified absolute path and "ToDo" task details. @@ -62,6 +64,14 @@ public CreateTodoCommand(AbsolutePath target, ToDo todo, Category category) { this.target = target; this.todo = todo; this.category = category; + this.isHelp = false; + } + + private CreateTodoCommand() { + this.target = null; + this.todo = null; + this.category = null; + this.isHelp = true; } /** @@ -74,6 +84,11 @@ public CreateTodoCommand(AbsolutePath target, ToDo todo, Category category) { @Override public CommandResult execute(Model model) throws CommandException { requireNonNull(model); + + if (isHelp) { + return new CommandResult(MESSAGE_USAGE); + } + // Check path exists in ProfBook if (!model.hasPath(target)) { throw new CommandException(MESSAGE_PATH_NOT_FOUND); diff --git a/src/main/java/seedu/address/logic/commands/DeleteForStudentsAndGroupsCommand.java b/src/main/java/seedu/address/logic/commands/DeleteForStudentsAndGroupsCommand.java index 2cff7242cf2..3e214127aae 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteForStudentsAndGroupsCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteForStudentsAndGroupsCommand.java @@ -36,9 +36,10 @@ public class DeleteForStudentsAndGroupsCommand extends Command { public static final String MESSAGE_NO_SUCH_STUDENT_OR_GROUP = "There is no such student or group to delete"; public static final String MESSAGE_DELETE_CURRENT_PATH = "Current path cannot be deleted"; public static final String MESSAGE_DELETE_DISPLAY_PATH = "Current display path cannot be deleted."; - protected Student stu; - protected Group grp; + public static final DeleteForStudentsAndGroupsCommand HELP_MESSAGE = new DeleteForStudentsAndGroupsCommand(); + private final AbsolutePath toBeDeleted; + private final boolean isHelp; /** * Creates an DeleteForStudentsAndGroupsCommand to specified {@code Student} or {@code Group} @@ -46,6 +47,12 @@ public class DeleteForStudentsAndGroupsCommand extends Command { public DeleteForStudentsAndGroupsCommand(AbsolutePath toBeDeleted) { //path will specify which grp/student requireNonNull(toBeDeleted); this.toBeDeleted = toBeDeleted; + this.isHelp = false; + } + + private DeleteForStudentsAndGroupsCommand() { + this.toBeDeleted = null; + this.isHelp = true; } /** @@ -61,6 +68,10 @@ public DeleteForStudentsAndGroupsCommand(AbsolutePath toBeDeleted) { //path will public CommandResult execute(Model model) throws CommandException { requireNonNull(model); + if (isHelp) { + return new CommandResult(MESSAGE_USAGE); + } + if (toBeDeleted.isRootDirectory()) { throw new CommandException(MESSAGE_INCORRECT_DIRECTORY_ERROR); } @@ -86,7 +97,7 @@ public CommandResult execute(Model model) throws CommandException { if (!target.hasChild(studentId)) { throw new CommandException(MESSAGE_NO_SUCH_STUDENT_OR_GROUP); } - stu = target.getChild(studentId); + Student stu = target.getChild(studentId); target.deleteChild(studentId); model.updateList(); return new CommandResult(String.format(MESSAGE_SUCCESS_FOR_STUDENT, Messages.format(stu))); @@ -98,7 +109,7 @@ public CommandResult execute(Model model) throws CommandException { if (!target.hasChild(groupId)) { throw new CommandException(MESSAGE_NO_SUCH_STUDENT_OR_GROUP); } - grp = target.getChild(groupId); + Group grp = target.getChild(groupId); target.deleteChild(groupId); model.updateList(); return new CommandResult(String.format(MESSAGE_SUCCESS_FOR_GROUP, Messages.format(grp))); diff --git a/src/main/java/seedu/address/logic/commands/DeleteTaskCommand.java b/src/main/java/seedu/address/logic/commands/DeleteTaskCommand.java index 743dc3c9846..4bd682fa1ba 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteTaskCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteTaskCommand.java @@ -25,9 +25,12 @@ public class DeleteTaskCommand extends Command { public static final String MESSAGE_TASK_LIST_NOT_SHOWN = "Current display panel is not displaying task list."; public static final String MESSAGE_INVALID_INDEX = "The task list provided is invalid."; public static final String MESSAGE_DELETE_TASK_SUCCESS = "Deleted task: %1$s"; + public static final DeleteTaskCommand HELP_MESSAGE = new DeleteTaskCommand(); + private static final Logger logger = LogsCenter.getLogger(DeleteTaskCommand.class); private final Index targetIndex; + private final boolean isHelp; /** * Construct a DeleteTaskCommand instance with target index. @@ -35,12 +38,22 @@ public class DeleteTaskCommand extends Command { public DeleteTaskCommand(Index targetIndex) { requireNonNull(targetIndex); this.targetIndex = targetIndex; + this.isHelp = false; + } + + private DeleteTaskCommand() { + this.targetIndex = null; + this.isHelp = true; } @Override public CommandResult execute(Model model) throws CommandException { requireNonNull(model); + if (isHelp) { + return new CommandResult(MESSAGE_USAGE); + } + logger.info("Executing delete task command..."); // Check if diplay panel is displaying task list diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 3a0c3114671..8584fcaa855 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -80,11 +80,12 @@ public class EditCommand extends Command { public static final String MESSAGE_NO_CHANGES_MADE = "The value(s) you provided is the same as the current value(s). No changes have been made."; - private final AbsolutePath target; - - private EditGroupDescriptor editGroupDescriptor; + public static final EditCommand HELP_MESSAGE = new EditCommand(); - private EditStudentDescriptor editStudentDescriptor; + private final AbsolutePath target; + private final EditGroupDescriptor editGroupDescriptor; + private final EditStudentDescriptor editStudentDescriptor; + private final boolean isHelp; /** * Constructs an EditCommand for editing a group's details. @@ -95,6 +96,8 @@ public class EditCommand extends Command { public EditCommand(AbsolutePath target, EditGroupDescriptor editGroupDescriptor) { this.target = target; this.editGroupDescriptor = new EditGroupDescriptor(editGroupDescriptor); + this.editStudentDescriptor = null; + this.isHelp = false; } /** @@ -106,6 +109,15 @@ public EditCommand(AbsolutePath target, EditGroupDescriptor editGroupDescriptor) public EditCommand(AbsolutePath target, EditStudentDescriptor editStudentDescriptor) { this.target = target; this.editStudentDescriptor = new EditStudentDescriptor(editStudentDescriptor); + this.editGroupDescriptor = null; + this.isHelp = false; + } + + private EditCommand() { + this.target = null; + this.editGroupDescriptor = null; + this.editStudentDescriptor = null; + this.isHelp = true; } /** @@ -119,6 +131,10 @@ public EditCommand(AbsolutePath target, EditStudentDescriptor editStudentDescrip public CommandResult execute(Model model) throws CommandException { requireNonNull(model); + if (this.isHelp) { + return new CommandResult(MESSAGE_USAGE); + } + // Check path exists in ProfBook if (!model.hasPath(target)) { throw new CommandException(MESSAGE_NO_SUCH_PATH); diff --git a/src/main/java/seedu/address/logic/commands/MarkCommand.java b/src/main/java/seedu/address/logic/commands/MarkCommand.java index 90cb4404551..c551f086791 100644 --- a/src/main/java/seedu/address/logic/commands/MarkCommand.java +++ b/src/main/java/seedu/address/logic/commands/MarkCommand.java @@ -21,18 +21,15 @@ public class MarkCommand extends Command { public static final String COMMAND_WORD = "mark"; - public static final String MESSAGE_INCORRECT_STATE = "The current model is not showing task list."; - public static final String MESSAGE_INVALID_INDEX = "The task index provided is invalid."; - public static final String MESSAGE_MARK_TASK_SUCCESS = "Marked task: %1$s"; - public static final String MESSAGE_USAGE = COMMAND_WORD + " [task index]"; + public static final MarkCommand HELP_MESSAGE = new MarkCommand(); private static final Logger logger = LogsCenter.getLogger(MarkCommand.class); - private final Index index; + private final boolean isHelp; /** * Constructs a MarkCommand with the specified task index to be marked. @@ -42,6 +39,12 @@ public class MarkCommand extends Command { public MarkCommand(Index index) { requireNonNull(index); this.index = index; + this.isHelp = false; + } + + private MarkCommand() { + this.index = null; + this.isHelp = true; } /** @@ -55,6 +58,10 @@ public MarkCommand(Index index) { public CommandResult execute(Model model) throws CommandException { requireNonNull(model); + if (isHelp) { + return new CommandResult(MESSAGE_USAGE); + } + logger.info("Executing mark task command..."); if (!model.isShowTaskList()) { diff --git a/src/main/java/seedu/address/logic/commands/MoveStudentToGroupCommand.java b/src/main/java/seedu/address/logic/commands/MoveStudentToGroupCommand.java index 50747dfddb7..ba1e42372ed 100644 --- a/src/main/java/seedu/address/logic/commands/MoveStudentToGroupCommand.java +++ b/src/main/java/seedu/address/logic/commands/MoveStudentToGroupCommand.java @@ -26,9 +26,11 @@ public class MoveStudentToGroupCommand extends Command { public static final String MESSAGE_MOVE_STUDENT_SUCCESS = "Student $1$s is moved to this group: %2$s"; public static final String MESSAGE_INVALID_MOVE_COMMAND = "Move command is invalid."; public static final String MESSAGE_USAGE = COMMAND_WORD + ": student"; + public static final MoveStudentToGroupCommand HELP_MESSAGE = new MoveStudentToGroupCommand(); private final AbsolutePath source; private final AbsolutePath dest; + private final boolean isHelp; /** * Constructs a {@code MoveStudentToGroupCommand} with the specified source and destination paths. @@ -40,6 +42,13 @@ public MoveStudentToGroupCommand(AbsolutePath source, AbsolutePath dest) { requireAllNonNull(source, dest); this.source = source; this.dest = dest; + this.isHelp = false; + } + + private MoveStudentToGroupCommand() { + this.source = null; + this.dest = null; + this.isHelp = true; } /** @@ -53,6 +62,10 @@ public MoveStudentToGroupCommand(AbsolutePath source, AbsolutePath dest) { public CommandResult execute(Model model) throws CommandException { requireNonNull(model); + if (isHelp) { + return new CommandResult(MESSAGE_USAGE); + } + // Check move student to group if (source.isStudentDirectory() && dest.isGroupDirectory()) { // Check student exists in ProfBook diff --git a/src/main/java/seedu/address/logic/commands/ShowChildrenListCommand.java b/src/main/java/seedu/address/logic/commands/ShowChildrenListCommand.java index 2f127fa86de..c9a39554936 100644 --- a/src/main/java/seedu/address/logic/commands/ShowChildrenListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ShowChildrenListCommand.java @@ -17,16 +17,31 @@ public class ShowChildrenListCommand extends Command { public static final String MESSAGE_PATH_NOT_FOUND = "Path does not exist in ProfBook: %1$s"; public static final String MESSAGE_NOT_CHILDREN_MANAGER = "Cannot show children list for this path: %1$s"; public static final String MESSAGE_USAGE = COMMAND_WORD; + public static final ShowChildrenListCommand HELP_MESSAGE = new ShowChildrenListCommand(true); private static final Logger logger = LogsCenter.getLogger(ShowTaskListCommand.class); private final AbsolutePath target; + private final boolean isHelp; + /** + * Constructs {@code ShowChildrenListCommand} that show children list of current directory. + */ public ShowChildrenListCommand() { target = null; + isHelp = false; } + /** + * Constructs {@code ShowChildrenListCommand} that show children list of path given. + */ public ShowChildrenListCommand(AbsolutePath path) { target = path; + isHelp = false; + } + + private ShowChildrenListCommand(boolean isHelp) { + target = null; + this.isHelp = true; } /** @@ -38,6 +53,10 @@ public ShowChildrenListCommand(AbsolutePath path) { */ @Override public CommandResult execute(Model model) throws CommandException { + if (isHelp) { + return new CommandResult(MESSAGE_USAGE); + } + if (target == null) { if (!model.hasChildrenListInCurrentPath()) { throw new CommandException(MESSAGE_NOT_CHILDREN_MANAGER); diff --git a/src/main/java/seedu/address/logic/commands/ShowTaskListCommand.java b/src/main/java/seedu/address/logic/commands/ShowTaskListCommand.java index dc8be14eb7e..97220138007 100644 --- a/src/main/java/seedu/address/logic/commands/ShowTaskListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ShowTaskListCommand.java @@ -17,16 +17,31 @@ public class ShowTaskListCommand extends Command { public static final String MESSAGE_PATH_NOT_FOUND = "Path does not exist in ProfBook: %1$s"; public static final String MESSAGE_NOT_TASK_MANAGER = "Cannot show task list for this path: %1$s"; public static final String MESSAGE_USAGE = COMMAND_WORD; + public static final ShowTaskListCommand HELP_MESSAGE = new ShowTaskListCommand(true); private static final Logger logger = LogsCenter.getLogger(ShowTaskListCommand.class); private final AbsolutePath target; + private final boolean isHelp; + /** + * Constructs {@code ShowChildrenListCommand} that show task list of current directory. + */ public ShowTaskListCommand() { target = null; + isHelp = false; } + /** + * Constructs {@code ShowChildrenListCommand} that show children list of path given. + */ public ShowTaskListCommand(AbsolutePath path) { target = path; + isHelp = false; + } + + private ShowTaskListCommand(boolean isHelp) { + target = null; + this.isHelp = true; } /** @@ -38,6 +53,10 @@ public ShowTaskListCommand(AbsolutePath path) { */ @Override public CommandResult execute(Model model) throws CommandException { + if (isHelp) { + return new CommandResult(MESSAGE_USAGE); + } + if (target == null) { AbsolutePath currPath = model.getCurrPath(); if (!model.hasTaskListInCurrentPath()) { diff --git a/src/main/java/seedu/address/logic/commands/UnmarkCommand.java b/src/main/java/seedu/address/logic/commands/UnmarkCommand.java index a1e01c74798..8f29bbb91bb 100644 --- a/src/main/java/seedu/address/logic/commands/UnmarkCommand.java +++ b/src/main/java/seedu/address/logic/commands/UnmarkCommand.java @@ -21,18 +21,16 @@ public class UnmarkCommand extends Command { public static final String COMMAND_WORD = "unmark"; - public static final String MESSAGE_INCORRECT_STATE = "The current model is not showing task list."; - public static final String MESSAGE_MARK_TASK_SUCCESS = "Unmarked task: %1$s"; - public static final String MESSAGE_USAGE = COMMAND_WORD + " [task index]"; - public static final String MESSAGE_INVALID_INDEX = "The task index provided is invalid."; + public static final UnmarkCommand HELP_MESSAGE = new UnmarkCommand(); private static final Logger logger = LogsCenter.getLogger(UnmarkCommand.class); private final Index index; + private final boolean isHelp; /** * Constructs an UnmarkCommand with the specified task index to be unmarked. @@ -42,6 +40,12 @@ public class UnmarkCommand extends Command { public UnmarkCommand(Index index) { requireNonNull(index); this.index = index; + isHelp = false; + } + + private UnmarkCommand() { + this.index = null; + isHelp = true; } /** @@ -55,6 +59,10 @@ public UnmarkCommand(Index index) { public CommandResult execute(Model model) throws CommandException { requireNonNull(model); + if (isHelp) { + return new CommandResult(MESSAGE_USAGE); + } + logger.info("Executing unmark task command..."); if (!model.isShowTaskList()) { diff --git a/src/main/java/seedu/address/logic/parser/ChangeDirectoryCommandParser.java b/src/main/java/seedu/address/logic/parser/ChangeDirectoryCommandParser.java index 148aa1eacbc..b784010956b 100644 --- a/src/main/java/seedu/address/logic/parser/ChangeDirectoryCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/ChangeDirectoryCommandParser.java @@ -1,6 +1,7 @@ package seedu.address.logic.parser; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; +import static seedu.address.logic.parser.CliSyntax.OPTION_HELP; import java.util.logging.Logger; @@ -11,7 +12,6 @@ import seedu.address.model.path.RelativePath; import seedu.address.model.path.exceptions.InvalidPathException; - /** * Parses input arguments and creates a new ChangeDirectoryCommand object */ @@ -28,7 +28,11 @@ public class ChangeDirectoryCommandParser implements Parser { * @throws ParseException if the user input does not conform the expected format */ public CreateGroupCommand parse(String args, AbsolutePath currPath) throws ParseException { - ParserUtil.verifyAllOptionsValid(args, OPTION_NAME); + ParserUtil.verifyAllOptionsValid(args, OPTION_NAME, OPTION_HELP); ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, OPTION_NAME); + ArgumentTokenizer.tokenize(args, OPTION_NAME, OPTION_HELP); + + if (ParserUtil.isOptionPresent(argMultimap, OPTION_HELP)) { + return CreateGroupCommand.HELP_MESSAGE; + } if (!ParserUtil.areOptionsPresent(argMultimap, OPTION_NAME) || argMultimap.getPreamble().isEmpty()) { throw new ParseException(String.format( diff --git a/src/main/java/seedu/address/logic/parser/CreateStudentCommandParser.java b/src/main/java/seedu/address/logic/parser/CreateStudentCommandParser.java index 4f0014eb56e..5c79bcbace0 100644 --- a/src/main/java/seedu/address/logic/parser/CreateStudentCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/CreateStudentCommandParser.java @@ -3,6 +3,7 @@ import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.logic.parser.CliSyntax.OPTION_ADDRESS; import static seedu.address.logic.parser.CliSyntax.OPTION_EMAIL; +import static seedu.address.logic.parser.CliSyntax.OPTION_HELP; import static seedu.address.logic.parser.CliSyntax.OPTION_NAME; import static seedu.address.logic.parser.CliSyntax.OPTION_PHONE; @@ -36,10 +37,14 @@ public class CreateStudentCommandParser implements Parser * @throws ParseException if the user input does not conform the expected format */ public CreateStudentCommand parse(String args, AbsolutePath currPath) throws ParseException { - ParserUtil.verifyAllOptionsValid(args, OPTION_NAME, OPTION_PHONE, OPTION_EMAIL, OPTION_ADDRESS); + ParserUtil.verifyAllOptionsValid(args, OPTION_NAME, OPTION_PHONE, OPTION_EMAIL, OPTION_ADDRESS, OPTION_HELP); ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, OPTION_NAME, OPTION_PHONE, OPTION_EMAIL, OPTION_ADDRESS); + ArgumentTokenizer.tokenize(args, OPTION_NAME, OPTION_PHONE, OPTION_EMAIL, OPTION_ADDRESS, OPTION_HELP); + + if (ParserUtil.isOptionPresent(argMultimap, OPTION_HELP)) { + return CreateStudentCommand.HELP_MESSAGE; + } if (!ParserUtil.areOptionsPresent(argMultimap, OPTION_NAME) || argMultimap.getPreamble().isEmpty()) { diff --git a/src/main/java/seedu/address/logic/parser/CreateTodoCommandParser.java b/src/main/java/seedu/address/logic/parser/CreateTodoCommandParser.java index 6e1ede66312..58a8a809c8f 100644 --- a/src/main/java/seedu/address/logic/parser/CreateTodoCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/CreateTodoCommandParser.java @@ -3,6 +3,7 @@ import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.logic.parser.CliSyntax.OPTION_ALL; import static seedu.address.logic.parser.CliSyntax.OPTION_DESC; +import static seedu.address.logic.parser.CliSyntax.OPTION_HELP; import seedu.address.logic.commands.Category; import seedu.address.logic.commands.CreateTodoCommand; @@ -26,10 +27,14 @@ public class CreateTodoCommandParser implements Parser { * @throws ParseException if the user input does not conform the expected format */ public CreateTodoCommand parse(String args, AbsolutePath currPath) throws ParseException { - ParserUtil.verifyAllOptionsValid(args, OPTION_DESC, OPTION_ALL); + ParserUtil.verifyAllOptionsValid(args, OPTION_DESC, OPTION_ALL, OPTION_HELP); ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, OPTION_DESC, OPTION_ALL); + ArgumentTokenizer.tokenize(args, OPTION_DESC, OPTION_ALL, OPTION_HELP); + + if (ParserUtil.isOptionPresent(argMultimap, OPTION_HELP)) { + return CreateTodoCommand.HELP_MESSAGE; + } if (!ParserUtil.areOptionsPresent(argMultimap, OPTION_DESC)) { throw new ParseException(String.format( diff --git a/src/main/java/seedu/address/logic/parser/DeleteForStudentsAndGroupsCommandParser.java b/src/main/java/seedu/address/logic/parser/DeleteForStudentsAndGroupsCommandParser.java index 4c907d8e82b..af58f58ef27 100644 --- a/src/main/java/seedu/address/logic/parser/DeleteForStudentsAndGroupsCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/DeleteForStudentsAndGroupsCommandParser.java @@ -1,8 +1,8 @@ package seedu.address.logic.parser; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; +import static seedu.address.logic.parser.CliSyntax.OPTION_HELP; -import seedu.address.logic.Messages; import seedu.address.logic.commands.DeleteForStudentsAndGroupsCommand; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.path.AbsolutePath; @@ -23,13 +23,14 @@ public class DeleteForStudentsAndGroupsCommandParser implements Parser { * @throws ParseException if the user input does not conform the expected format */ public DeleteTaskCommand parse(String args, AbsolutePath currPath) throws ParseException { + ParserUtil.verifyAllOptionsValid(args, OPTION_HELP); + + ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, OPTION_HELP); + + if (ParserUtil.isOptionPresent(argMultimap, OPTION_HELP)) { + return DeleteTaskCommand.HELP_MESSAGE; + } + + if (argMultimap.getPreamble().isEmpty()) { + throw new ParseException(String.format( + MESSAGE_INVALID_COMMAND_FORMAT, DeleteTaskCommand.MESSAGE_USAGE)); + } + logger.fine("Parsing delete task command with arguments: " + args); if (!ArgumentTokenizer.extractAllOptionNames(args).isEmpty()) { throw new ParseException(String.format(Messages.MESSAGE_NO_OPTIONS, diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index 7ecbe33d499..6f8ab11d6e3 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -3,6 +3,7 @@ import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; import static seedu.address.logic.parser.CliSyntax.OPTION_ADDRESS; import static seedu.address.logic.parser.CliSyntax.OPTION_EMAIL; +import static seedu.address.logic.parser.CliSyntax.OPTION_HELP; import static seedu.address.logic.parser.CliSyntax.OPTION_ID; import static seedu.address.logic.parser.CliSyntax.OPTION_NAME; import static seedu.address.logic.parser.CliSyntax.OPTION_PHONE; @@ -31,13 +32,19 @@ public class EditCommandParser implements Parser { public EditCommand parse(String args, AbsolutePath currPath) throws ParseException { requireAllNonNull(args, currPath); + ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, OPTION_HELP); + + if (ParserUtil.isOptionPresent(argMultimap, OPTION_HELP)) { + return EditCommand.HELP_MESSAGE; + } + String preamble = ArgumentTokenizer.extractPreamble(args); - RelativePath path = ParserUtil.parseRelativePath(preamble); AbsolutePath targetPath = null; if (preamble.isEmpty()) { targetPath = currPath; } else { + RelativePath path = ParserUtil.parseRelativePath(preamble); targetPath = ParserUtil.resolvePath(currPath, path); } @@ -57,7 +64,8 @@ private EditCommand parseEditStudent(String args, AbsolutePath target) throws Pa OPTION_NAME, OPTION_PHONE, OPTION_EMAIL, OPTION_ADDRESS, OPTION_ID); ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, OPTION_NAME, OPTION_PHONE, OPTION_EMAIL, OPTION_ADDRESS, OPTION_ID); + ArgumentTokenizer.tokenize(args, + OPTION_NAME, OPTION_PHONE, OPTION_EMAIL, OPTION_ADDRESS, OPTION_ID); argMultimap.verifyNoDuplicateOptionsFor(OPTION_NAME, OPTION_PHONE, OPTION_EMAIL, OPTION_ADDRESS, OPTION_ID); diff --git a/src/main/java/seedu/address/logic/parser/MarkCommandParser.java b/src/main/java/seedu/address/logic/parser/MarkCommandParser.java index 0d09fe2c7e3..ce3d66ff4ae 100644 --- a/src/main/java/seedu/address/logic/parser/MarkCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/MarkCommandParser.java @@ -1,10 +1,11 @@ package seedu.address.logic.parser; +import static seedu.address.logic.parser.CliSyntax.OPTION_HELP; + import java.util.logging.Logger; import seedu.address.commons.core.LogsCenter; import seedu.address.commons.core.index.Index; -import seedu.address.logic.Messages; import seedu.address.logic.commands.MarkCommand; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.path.AbsolutePath; @@ -27,9 +28,12 @@ public class MarkCommandParser implements Parser { */ public MarkCommand parse(String args, AbsolutePath currPath) throws ParseException { logger.fine("Parsing mark task command with arguments: " + args); - if (!ArgumentTokenizer.extractAllOptionNames(args).isEmpty()) { - throw new ParseException(String.format(Messages.MESSAGE_NO_OPTIONS, - MarkCommand.COMMAND_WORD)); + ParserUtil.verifyAllOptionsValid(args, OPTION_HELP); + + ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, OPTION_HELP); + + if (ParserUtil.isOptionPresent(argMultimap, OPTION_HELP)) { + return MarkCommand.HELP_MESSAGE; } Index index = ParserUtil.parseIndex(args); diff --git a/src/main/java/seedu/address/logic/parser/MoveStudentToGroupCommandParser.java b/src/main/java/seedu/address/logic/parser/MoveStudentToGroupCommandParser.java index a801f9cbc38..349d89f7461 100644 --- a/src/main/java/seedu/address/logic/parser/MoveStudentToGroupCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/MoveStudentToGroupCommandParser.java @@ -1,9 +1,8 @@ package seedu.address.logic.parser; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; +import static seedu.address.logic.parser.CliSyntax.OPTION_HELP; -import seedu.address.logic.Messages; -import seedu.address.logic.commands.DeleteTaskCommand; import seedu.address.logic.commands.MoveStudentToGroupCommand; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.path.AbsolutePath; @@ -25,13 +24,13 @@ public class MoveStudentToGroupCommandParser implements Parser { * @throws ParseException if the user input does not conform the expected format */ public ShowTaskListCommand parse(String args, AbsolutePath currPath) throws ParseException { - if (!ArgumentTokenizer.extractAllOptionNames(args).isEmpty()) { - throw new ParseException(String.format(Messages.MESSAGE_NO_OPTIONS, - DeleteTaskCommand.COMMAND_WORD)); - } + ParserUtil.verifyAllOptionsValid(args, OPTION_HELP); - ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args); + ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, OPTION_HELP); + + if (ParserUtil.isOptionPresent(argMultimap, OPTION_HELP)) { + return ShowTaskListCommand.HELP_MESSAGE; + } if (argMultimap.getPreamble().isEmpty()) { logger.fine(String.format(MESSAGE_COMMAND_CREATED, "Current directory")); diff --git a/src/main/java/seedu/address/logic/parser/UnmarkCommandParser.java b/src/main/java/seedu/address/logic/parser/UnmarkCommandParser.java index a55222985b5..f808edce4a7 100644 --- a/src/main/java/seedu/address/logic/parser/UnmarkCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/UnmarkCommandParser.java @@ -1,10 +1,11 @@ package seedu.address.logic.parser; +import static seedu.address.logic.parser.CliSyntax.OPTION_HELP; + import java.util.logging.Logger; import seedu.address.commons.core.LogsCenter; import seedu.address.commons.core.index.Index; -import seedu.address.logic.Messages; import seedu.address.logic.commands.UnmarkCommand; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.path.AbsolutePath; @@ -29,10 +30,14 @@ public UnmarkCommand parse(String args, AbsolutePath currPath) throws ParseExcep logger.fine("Parsing unmark task command with arguments: " + args); - if (!ArgumentTokenizer.extractAllOptionNames(args).isEmpty()) { - throw new ParseException(String.format(Messages.MESSAGE_NO_OPTIONS, - UnmarkCommand.COMMAND_WORD)); + ParserUtil.verifyAllOptionsValid(args, OPTION_HELP); + + ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, OPTION_HELP); + + if (ParserUtil.isOptionPresent(argMultimap, OPTION_HELP)) { + return UnmarkCommand.HELP_MESSAGE; } + Index index = ParserUtil.parseIndex(args); logger.fine("Index parsed (One Based): " + index.getOneBased()); return new UnmarkCommand(index);