Skip to content

Commit

Permalink
Merge branch 'master' into w11/update-dg
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugenetanwl3881 authored Oct 27, 2022
2 parents 4ae8f93 + 67090b6 commit 0457595
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/main/java/seedu/foodrem/logic/parser/FoodRemParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
import seedu.foodrem.commons.core.Messages;
import seedu.foodrem.commons.enums.CommandType;
import seedu.foodrem.logic.commands.Command;
import seedu.foodrem.logic.commands.generalcommands.ExitCommand;
import seedu.foodrem.logic.commands.generalcommands.HelpCommand;
import seedu.foodrem.logic.commands.generalcommands.ResetCommand;
import seedu.foodrem.logic.commands.itemcommands.ListCommand;
import seedu.foodrem.logic.commands.tagcommands.ListTagCommand;
import seedu.foodrem.logic.parser.exceptions.ParseException;
import seedu.foodrem.logic.parser.generalcommandparser.ExitCommandParser;
import seedu.foodrem.logic.parser.generalcommandparser.HelpCommandParser;
import seedu.foodrem.logic.parser.generalcommandparser.ResetCommandParser;
import seedu.foodrem.logic.parser.itemcommandparser.DecrementCommandParser;
import seedu.foodrem.logic.parser.itemcommandparser.DeleteCommandParser;
import seedu.foodrem.logic.parser.itemcommandparser.EditCommandParser;
import seedu.foodrem.logic.parser.itemcommandparser.FilterTagCommandParser;
import seedu.foodrem.logic.parser.itemcommandparser.FindCommandParser;
import seedu.foodrem.logic.parser.itemcommandparser.IncrementCommandParser;
import seedu.foodrem.logic.parser.itemcommandparser.ListCommandParser;
import seedu.foodrem.logic.parser.itemcommandparser.NewCommandParser;
import seedu.foodrem.logic.parser.itemcommandparser.RemarkCommandParser;
import seedu.foodrem.logic.parser.itemcommandparser.SortCommandParser;
Expand Down Expand Up @@ -80,15 +80,15 @@ public Command parseCommand(String userInput) throws ParseException {
case DELETE_TAG_COMMAND:
return new DeleteTagCommandParser().parse(arguments);
case RESET_COMMAND:
return new ResetCommand();
return new ResetCommandParser().parse(arguments);
case FIND_COMMAND:
return new FindCommandParser().parse(arguments);
case LIST_COMMAND:
return new ListCommand();
return new ListCommandParser().parse(arguments);
case SORT_COMMAND:
return new SortCommandParser().parse(arguments);
case EXIT_COMMAND:
return new ExitCommand();
return new ExitCommandParser().parse(arguments);
case HELP_COMMAND:
return new HelpCommandParser().parse(arguments);
case TAG_COMMAND:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package seedu.foodrem.logic.parser.generalcommandparser;

import static java.util.Objects.requireNonNull;

import seedu.foodrem.commons.core.Messages;
import seedu.foodrem.logic.commands.generalcommands.ExitCommand;
import seedu.foodrem.logic.parser.Parser;
import seedu.foodrem.logic.parser.exceptions.ParseException;

/**
* Parses input arguments and creates a ExitCommand object.
*/
public class ExitCommandParser implements Parser<ExitCommand> {
/**
* Parses the given {@code String} of arguments in the context of the ExitCommand
* and returns an ExitCommand object for execution.
*
* @throws ParseException if the user input does not conform the expected format
*/
public ExitCommand parse(String args) throws ParseException {
requireNonNull(args);

if (!args.trim().isBlank()) {
throw new ParseException(String.format(Messages.MESSAGE_INVALID_COMMAND_FORMAT, ExitCommand.getUsage()));
}

return new ExitCommand();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package seedu.foodrem.logic.parser.generalcommandparser;

import static java.util.Objects.requireNonNull;

import seedu.foodrem.commons.core.Messages;
import seedu.foodrem.logic.commands.generalcommands.ResetCommand;
import seedu.foodrem.logic.parser.Parser;
import seedu.foodrem.logic.parser.exceptions.ParseException;

/**
* Parses input arguments and creates a ResetCommand object.
*/
public class ResetCommandParser implements Parser<ResetCommand> {
/**
* Parses the given {@code String} of arguments in the context of the ResetCommand
* and returns an ResetCommand object for execution.
*
* @throws ParseException if the user input does not conform the expected format
*/
public ResetCommand parse(String args) throws ParseException {
requireNonNull(args);

if (!args.trim().isBlank()) {
throw new ParseException(String.format(Messages.MESSAGE_INVALID_COMMAND_FORMAT, ResetCommand.getUsage()));
}

return new ResetCommand();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package seedu.foodrem.logic.parser.itemcommandparser;

import static java.util.Objects.requireNonNull;

import seedu.foodrem.commons.core.Messages;
import seedu.foodrem.logic.commands.itemcommands.ListCommand;
import seedu.foodrem.logic.parser.Parser;
import seedu.foodrem.logic.parser.exceptions.ParseException;

/**
* Parses input arguments and creates a ListCommand object.
*/
public class ListCommandParser implements Parser<ListCommand> {
/**
* Parses the given {@code String} of arguments in the context of the ListCommand
* and returns an ListCommand object for execution.
*
* @throws ParseException if the user input does not conform the expected format
*/
public ListCommand parse(String args) throws ParseException {
requireNonNull(args);

if (!args.trim().isBlank()) {
throw new ParseException(String.format(Messages.MESSAGE_INVALID_COMMAND_FORMAT, ListCommand.getUsage()));
}

return new ListCommand();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ public void parseCommand_help() {
@Test
public void parseCommand_clear() {
assertTrue(parser.parseCommand(CommandType.RESET_COMMAND.getCommandWord()) instanceof ResetCommand);
assertTrue(parser.parseCommand(CommandType.RESET_COMMAND.getCommandWord() + " 3") instanceof ResetCommand);
}

@Test
public void parseCommand_exit() {
assertTrue(parser.parseCommand(CommandType.EXIT_COMMAND.getCommandWord()) instanceof ExitCommand);
assertTrue(parser.parseCommand(CommandType.EXIT_COMMAND.getCommandWord() + " 3") instanceof ExitCommand);
}

// Item Commands
Expand Down Expand Up @@ -103,8 +101,6 @@ public void parseCommand_find() {
@Test
public void parseCommand_list() {
assertTrue(parser.parseCommand(CommandType.LIST_COMMAND.getCommandWord()) instanceof ListCommand);
assertTrue(parser.parseCommand(CommandType.LIST_COMMAND.getCommandWord()
+ " 1") instanceof ListCommand);
}

@Test
Expand Down

0 comments on commit 0457595

Please sign in to comment.