Skip to content

Commit

Permalink
Merge pull request AY2324S1-CS2103T-W08-3#191
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ-Lee01 authored Nov 13, 2023
2 parents 8debdcf + b210936 commit 78d5577
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public ReminderCommand parse(String args) throws ParseException {
ArgumentTokenizer.tokenize(args,
ReminderCommand.AUTOCOMPLETE_SUPPLIER.getAllPossibleFlags().toArray(Flag[]::new));

argMultimap.verifyAtMostOneOfFlagsUsedOutOf(FLAG_EARLIEST, FLAG_LATEST);

if (argMultimap.hasFlag(FLAG_EARLIEST)) {
return new ReminderCommand(true);
} else if (argMultimap.hasFlag(FLAG_LATEST)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.FLAG_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.FLAG_ASCENDING;
import static seedu.address.logic.parser.CliSyntax.FLAG_DEADLINE;
import static seedu.address.logic.parser.CliSyntax.FLAG_DESCENDING;
import static seedu.address.logic.parser.CliSyntax.FLAG_EMAIL;
Expand Down Expand Up @@ -48,6 +49,11 @@ public SortCommand parse(String args) throws ParseException {
ArgumentTokenizer.tokenize(args,
SortCommand.AUTOCOMPLETE_SUPPLIER.getAllPossibleFlags().toArray(Flag[]::new));

argMultimap.verifyAtMostOneOfFlagsUsedOutOf(FLAG_NONE, FLAG_ADDRESS, FLAG_EMAIL,
FLAG_ID, FLAG_NAME, FLAG_PHONE, FLAG_URL, FLAG_DEADLINE, FLAG_STAGE, FLAG_STALE,
FLAG_STATUS, FLAG_TITLE);
argMultimap.verifyAtMostOneOfFlagsUsedOutOf(FLAG_NONE, FLAG_ASCENDING, FLAG_DESCENDING);

if (argMultimap.hasFlag(FLAG_NONE)) {
return new SortCommand(null, null, true);
}
Expand All @@ -59,7 +65,7 @@ public SortCommand parse(String args) throws ParseException {
if (argMultimap.hasFlag(FLAG_DESCENDING)) {
isReverse = true;
}
//I feel there should be a more elegant way to write this.

if (argMultimap.hasFlag(FLAG_ADDRESS)) {
if (isReverse) {
contactComparator = COMPARATOR_ADDRESS_REVERSED;
Expand Down

0 comments on commit 78d5577

Please sign in to comment.