Skip to content

Commit

Permalink
Merge pull request #56 from connlim/branch-task-commands
Browse files Browse the repository at this point in the history
Improve Task command keywords
  • Loading branch information
Eclipse-Dominator committed Oct 27, 2022
2 parents 1b6d337 + 60cd7ef commit 654d884
Show file tree
Hide file tree
Showing 14 changed files with 204 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_DESCRIPTION;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TITLE;

import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.task.Task;

//@@author connlim

/**
* Create a task and assign it to a group
*/
public class AddTaskCommand extends Command {
public static final String COMMAND_WORD = "task";
public class AddTaskCommand extends TaskCommand {
public static final String SUBCOMMAND_WORD = "add";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a task to the address book current team. "
+ "Parameters: "
+ PREFIX_TITLE + "NAME "
+ PREFIX_DESCRIPTION + "Description";
public static final String MESSAGE_USAGE =
TaskCommand.getFullCommand(SUBCOMMAND_WORD) + ": Adds a task to the address book current team. "
+ "Parameters: " + PREFIX_TITLE + "NAME " + PREFIX_DESCRIPTION + "Description";

public static final String MESSAGE_SUCCESS = "New task have been added: %1$s";
public static final String MESSAGE_DUPLICATE_TASK = "This task already exists!";
Expand Down Expand Up @@ -55,6 +54,6 @@ public CommandResult execute(Model model) throws CommandException {
public boolean equals(Object other) {
return other == this // short circuit if same object
|| (other instanceof AddTaskCommand // instanceof handles nulls
&& toAdd.equals(((AddTaskCommand) other).toAdd));
&& toAdd.equals(((AddTaskCommand) other).toAdd));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.task.Task;

//@@author mohamedsaf1
/**
* Removes a task from Contactmation
* Deletes a task from Contactmation.
*
* @author connlim
* @author mohamedsaf1
*/
public class RmTaskCommand extends Command {
public static final String COMMAND_WORD = "rmTask";
public class DeleteTaskCommand extends TaskCommand {
public static final String SUBCOMMAND_WORD = "delete";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Delete the selected task\n"
+ "Parameters: INDEX (must be a positive integer)\n"
+ "Example: " + COMMAND_WORD + " 1\n";
public static final String MESSAGE_USAGE =
TaskCommand.getFullCommand(SUBCOMMAND_WORD) + ": Delete the selected task\n"
+ "Parameters: INDEX (must be a positive integer)\n" + "Example: " + COMMAND_WORD + " 1\n";

public static final String DELETE_SUCCESS = " task %s is deleted%n";

private final Index targetIndex;

public RmTaskCommand(Index targetIndex) {
public DeleteTaskCommand(Index targetIndex) {
this.targetIndex = targetIndex;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,29 @@

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.task.Task;

//@@author connlim

/**
* Marks a task as complete
*/
public class MarkCommand extends Command {
public static final String COMMAND_WORD = "mark";
public class MarkTaskCommand extends TaskCommand {
public static final String SUBCOMMAND_WORD = "mark";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Marks the task as completed\n"
+ "Parameters: INDEX (must be a positive integer)\n"
+ "Example: " + COMMAND_WORD + " 1\n";
public static final String MESSAGE_USAGE =
TaskCommand.getFullCommand(SUBCOMMAND_WORD) + ": Marks the task as completed\n"
+ "Parameters: INDEX (must be a positive integer)\n" + "Example: " + COMMAND_WORD + " 1\n";

public static final String COMPLETE_SUCESS = " task %s is marked as complete%n";
public static final String ALREADY_MARKED = " task %s is already completed%n";

private final Index targetIndex;

public MarkCommand(Index targetIndex) {
public MarkTaskCommand(Index targetIndex) {
this.targetIndex = targetIndex;
}

Expand Down
21 changes: 21 additions & 0 deletions src/main/java/seedu/address/logic/commands/tasks/TaskCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package seedu.address.logic.commands.tasks;

import seedu.address.logic.commands.Command;

/**
* Commands for Tasks
*/
public abstract class TaskCommand extends Command {

public static final String COMMAND_WORD = "task";

/**
* Returns the complete command phrase for the task command with given subCommand
*
* @param subcommand The subcommand to be added
* @return The complete command phrase
*/
static String getFullCommand(String subcommand) {
return "task " + subcommand;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,29 @@

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.task.Task;

//@@author connlim

/**
* Unmarks a task as complete.
*/
public class UnmarkCommand extends Command {
public static final String COMMAND_WORD = "unmark";
public class UnmarkTaskCommand extends TaskCommand {
public static final String SUBCOMMAND_WORD = "unmark";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Marks the task as incompleted\n"
+ "Parameters: INDEX (must be a positive integer)\n"
+ "Example: " + COMMAND_WORD + " 1\n";
public static final String MESSAGE_USAGE =
TaskCommand.getFullCommand(SUBCOMMAND_WORD) + ": Marks the task as incomplete\n"
+ "Parameters: INDEX (must be a positive integer)\n" + "Example: " + COMMAND_WORD + " 1\n";

public static final String ALREADY_UNMARKED = " task %s is already incompleted%n";
public static final String ALREADY_UNMARKED = " task %s is already incomplete%n";
public static final String UNMARK_SUCCESS = " task %s is marked as incomplete%n";

private final Index targetIndex;

public UnmarkCommand(Index targetIndex) {
public UnmarkTaskCommand(Index targetIndex) {
this.targetIndex = targetIndex;
}

Expand Down
19 changes: 4 additions & 15 deletions src/main/java/seedu/address/logic/parser/AddressBookParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@
import seedu.address.logic.commands.HelpCommand;
import seedu.address.logic.commands.ListCommand;
import seedu.address.logic.commands.RemoveFieldCommand;
import seedu.address.logic.commands.tasks.AddTaskCommand;
import seedu.address.logic.commands.tasks.MarkCommand;
import seedu.address.logic.commands.tasks.RmTaskCommand;
import seedu.address.logic.commands.tasks.UnmarkCommand;
import seedu.address.logic.commands.tasks.TaskCommand;
import seedu.address.logic.commands.teams.AddTeamCommand;
import seedu.address.logic.commands.teams.AddUserToTeamCommand;
import seedu.address.logic.commands.teams.ChangeTeamCommand;
import seedu.address.logic.commands.teams.DeleteTeamCommand;
import seedu.address.logic.commands.teams.RemoveUserFromTeamCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.logic.parser.tasks.TaskCommandParser;

/**
* Parses user input.
Expand Down Expand Up @@ -90,17 +88,8 @@ public Command parseCommand(String userInput) throws ParseException {
case ChangeTeamCommand.COMMAND_WORD:
return new ChangeTeamCommandParser().parse(arguments);

case MarkCommand.COMMAND_WORD:
return new MarkCommandParser().parse(arguments);

case UnmarkCommand.COMMAND_WORD:
return new UnmarkCommandParser().parse(arguments);

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

case RmTaskCommand.COMMAND_WORD:
return new RmTaskCommandParser().parse(arguments);
case TaskCommand.COMMAND_WORD:
return new TaskCommandParser().parse(arguments);

case DeleteTeamCommand.COMMAND_WORD:
return new DeleteTeamCommandParser().parse(arguments);
Expand Down
26 changes: 0 additions & 26 deletions src/main/java/seedu/address/logic/parser/MarkCommandParser.java

This file was deleted.

27 changes: 0 additions & 27 deletions src/main/java/seedu/address/logic/parser/RmTaskCommandParser.java

This file was deleted.

26 changes: 0 additions & 26 deletions src/main/java/seedu/address/logic/parser/UnmarkCommandParser.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address.logic.parser;
package seedu.address.logic.parser.tasks;

import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DESCRIPTION;
Expand All @@ -7,6 +7,10 @@
import java.util.stream.Stream;

import seedu.address.logic.commands.tasks.AddTaskCommand;
import seedu.address.logic.parser.ArgumentMultimap;
import seedu.address.logic.parser.ArgumentTokenizer;
import seedu.address.logic.parser.Parser;
import seedu.address.logic.parser.Prefix;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.task.Task;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package seedu.address.logic.parser.tasks;

import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.tasks.DeleteTaskCommand;
import seedu.address.logic.parser.Parser;
import seedu.address.logic.parser.ParserUtil;
import seedu.address.logic.parser.exceptions.ParseException;

//@@author mohamedsaf1

/**
* Parses input arguments and creates a new RmTaskCommand object
*/
public class DeleteTaskCommandParser implements Parser<DeleteTaskCommand> {

@Override
public DeleteTaskCommand parse(String args) throws ParseException {
try {
Index index = ParserUtil.parseIndex(args);
return new DeleteTaskCommand(index);
} catch (ParseException pe) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteTaskCommand.MESSAGE_USAGE),
pe);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package seedu.address.logic.parser.tasks;

import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.tasks.MarkTaskCommand;
import seedu.address.logic.parser.Parser;
import seedu.address.logic.parser.ParserUtil;
import seedu.address.logic.parser.exceptions.ParseException;

//@@author connlim
/**
* Parses input arguments and creates a new MarkTaskCommand object
*/
public class MarkTaskCommandParser implements Parser<MarkTaskCommand> {

@Override
public MarkTaskCommand parse(String args) throws ParseException {
try {
Index index = ParserUtil.parseIndex(args);
return new MarkTaskCommand(index);
} catch (ParseException pe) {
throw new ParseException(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, MarkTaskCommand.MESSAGE_USAGE), pe);
}
}

}
Loading

0 comments on commit 654d884

Please sign in to comment.