-
Notifications
You must be signed in to change notification settings - Fork 458
Expand file tree
/
Copy pathRemarkCommandParser.java
More file actions
44 lines (38 loc) · 1.74 KB
/
RemarkCommandParser.java
File metadata and controls
44 lines (38 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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_REMARK;
import seedu.address.commons.core.index.Index;
import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.logic.commands.RemarkCommand;
import seedu.address.logic.parser.ArgumentMultimap;
import seedu.address.logic.parser.ArgumentTokenizer;
import seedu.address.logic.parser.ParserUtil;
import seedu.address.logic.parser.Parser;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Remark;
/**
* Parses input arguments and creates a new {@code RemarkCommand} object.
*/
public class RemarkCommandParser implements Parser<RemarkCommand> {
/**
* Parses the given {@code String} of arguments in the context of the {@code RemarkCommand}
* and returns a {@code RemarkCommand} object for execution.
*
* @param args input arguments
* @return RemarkCommand object for execution
* @throws ParseException if the user input does not conform the expected format
*/
public RemarkCommand parse(String args) throws ParseException {
requireNonNull(args);
ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_REMARK);
Index index;
try {
index = ParserUtil.parseIndex(argMultimap.getPreamble());
} catch (IllegalValueException ive) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, RemarkCommand.MESSAGE_USAGE), ive);
}
String remark = argMultimap.getValue(PREFIX_REMARK).orElse("");
return new RemarkCommand(index, remark);
}
}