Skip to content

Commit

Permalink
Fix read command parser and read command exceptions and update shadow…
Browse files Browse the repository at this point in the history
… jar file name
  • Loading branch information
NatLeong committed Mar 24, 2024
1 parent 0586070 commit 46cd263
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ dependencies {
}

shadowJar {
archiveFileName = 'addressbook.jar'
archiveFileName = 'immuniMate.jar'
}

defaultTasks 'clean', 'test'
6 changes: 3 additions & 3 deletions src/main/java/seedu/address/logic/commands/ReadCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class ReadCommand extends Command {
+ PREFIX_NRIC + "T0123456A";

public static final String MESSAGE_READ_PERSON_SUCCESS = "Read Person: %1$s";
public static final String MESSAGE_NO_PERSON = "There is no such person with this NRIC.";
public static final String MESSAGE_NOT_READ = "NRIC to be specified.";
private final Nric nric;

Expand All @@ -41,8 +40,9 @@ public ReadCommand(Nric nric) {
@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
if (model.hasPerson(Person.createPersonWithNric(nric))) {
throw new CommandException(MESSAGE_NO_PERSON);

if (!model.hasPerson(Person.createPersonWithNric(nric))) {
throw new CommandException(Messages.MESSAGE_PERSON_NOT_FOUND);
}

model.updateFilteredPersonList(new NricContainsKeywordsPredicate(nric.toString()));
Expand Down
19 changes: 14 additions & 5 deletions src/main/java/seedu/address/logic/parser/ReadCommandParser.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package seedu.address.logic.parser;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NRIC;

import seedu.address.logic.commands.FindCommand;
import seedu.address.logic.commands.ReadCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Nric;

/**
* Parses input arguments and creates a new ReadCommand object
Expand All @@ -17,13 +20,19 @@ public class ReadCommandParser implements Parser<ReadCommand> {
*/
public ReadCommand parse(String args) throws ParseException {
requireNonNull(args);
ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NRIC);

if (argMultimap.getValue(PREFIX_NRIC).isEmpty()) {
throw new ParseException(ReadCommand.MESSAGE_NOT_READ);
String trimmed_Arg = args.trim();
if (trimmed_Arg.isEmpty()) {
throw new ParseException(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, ReadCommand.MESSAGE_NOT_READ));
}
//ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NRIC);

//if (argMultimap.getValue(PREFIX_NRIC).isEmpty()) {
// throw new ParseException(ReadCommand.MESSAGE_NOT_READ);
//}

return new ReadCommand(ParserUtil.parseNric(argMultimap.getValue(PREFIX_NRIC).get()));
//return new ReadCommand(ParserUtil.parseNric(argMultimap.getValue(PREFIX_NRIC).get()));
return new ReadCommand(new Nric(trimmed_Arg));
}
}

0 comments on commit 46cd263

Please sign in to comment.