forked from nus-cs2103-AY1718S1/addressbook-level4-old
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from ZhangH795/1.3_Enhancement
1.3 enhancement
- Loading branch information
Showing
19 changed files
with
392 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,33 +205,36 @@ Format: `t-add [TAG] INDEX` | |
* Adds tag to the person(s) at the specified `INDEX`. | ||
* The index refers to the index number shown in the most recent listing, multiple indices are allowed. | ||
* The index *must be a positive integer* 1, 2, 3, ... | ||
* The [TAG] *must not have its first word as number* | ||
**** | ||
|
||
Examples: | ||
|
||
* `list` + | ||
`t-add friends 2 3` + | ||
`t-add 2 3 friends` + | ||
Adds the tag friends to the 2nd and 3rd person in the address book | ||
|
||
=== Removing a tag to a person(s) : `t-remove` _[Since v1.2]_ | ||
|
||
Removes a tag from specified person(s) from the address book. + | ||
Format: `t-remove [TAG] INDEX` | ||
Format: `t-remove INDEX... [TAG]` | ||
|
||
**** | ||
* Removes a tag from the person(s) at the specified `INDEX`. | ||
* The index refers to the index number shown in the most recent listing, multiple indices are allowed. | ||
* The index *must be a positive integer* 1, 2, 3, ... | ||
* The [TAG] *must not have its first word as number* | ||
**** | ||
|
||
Examples: | ||
|
||
* `list` + | ||
`t-remove friends 2 3` + | ||
`t-remove 2 3 friends` + | ||
Removes the tag friends from the 2nd and 3rd person in the address book | ||
|
||
=== Find the person(s) with given tags: `t-find` _[Since v1.3]_ | ||
Format: `t-find TAG TAG..` | ||
|
||
Format: `t-find TAG` | ||
|
||
**** | ||
* Find the person(s) with given tags. | ||
|
@@ -421,8 +424,12 @@ e.g. `add n/James Ho p/22224444 e/[email protected] a/123, Clementi Rd, 123466 | |
e.g. `delete 3 4` | ||
* *Edit* : `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [t/TAG]...` + | ||
e.g. `edit 2 n/James Lee e/[email protected]` | ||
* *TagAdd* : `t-add [TAG] INDEX INDEX...` + | ||
e.g. `t-add friends 3 4` | ||
* *TagAdd* : `t-add INDEX INDEX... [TAG]` + | ||
e.g. `t-add 3 4 friends` | ||
* *TagFind* : `t-find [TAG]` + | ||
e.g. `t-find friends` | ||
* *TagRemove* : `t-remove INDEX INDEX... [TAG]` + | ||
e.g. `t-remove 3 4 friends` | ||
* *Find* : `find KEYWORD [MORE_KEYWORDS]` + | ||
e.g. `find James Jake` | ||
* *Sort* : `sort [n/(ASC/DSC)] [p/(ASC/DSC)] [e/(ASC/DSC)] [a/(ASC/DSC)]` + | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/seedu/address/logic/commands/TagFindCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import seedu.address.model.tag.TagMatchingKeywordPredicate; | ||
|
||
/** | ||
* Finds and lists all persons in address book whose name contains a certain tag. | ||
* Keyword matching is case insensitive. | ||
*/ | ||
public class TagFindCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "t-find"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose tags contain any of " | ||
+ "the specified keywords (case-sensitive) and displays them as a list with index numbers.\n" | ||
+ "Parameters: [TAG] \n" | ||
+ "Example: " + COMMAND_WORD + " " + "friends"; | ||
|
||
private final TagMatchingKeywordPredicate predicate; | ||
|
||
public TagFindCommand(TagMatchingKeywordPredicate keywordPredicate) { | ||
this.predicate = keywordPredicate; | ||
} | ||
|
||
@Override | ||
public CommandResult execute() { | ||
model.updateFilteredPersonList(predicate); | ||
return new CommandResult(getMessageForPersonListShownSummary(model.getFilteredPersonList().size())); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (other instanceof TagFindCommand // instanceof handles nulls | ||
&& this.predicate.equals(((TagFindCommand) other).predicate)); // state check | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/seedu/address/logic/parser/TagFindCommandParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
|
||
import seedu.address.logic.commands.TagFindCommand; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
import seedu.address.model.tag.TagMatchingKeywordPredicate; | ||
|
||
/** | ||
* Parses input arguments and creates a new TagFindCommand object | ||
*/ | ||
public class TagFindCommandParser implements Parser<TagFindCommand> { | ||
/** | ||
* Parses the given {@code String} of arguments in the context of the TagFindCommand | ||
* and returns an TagFindCommand object for execution. | ||
* @throws ParseException if the user does not provide any input | ||
*/ | ||
public TagFindCommand parse(String args) throws ParseException { | ||
String trimmedArgs = args.trim(); | ||
//Throw an error if there is no argument followed by the command word | ||
if (trimmedArgs.isEmpty()) { | ||
throw new ParseException( | ||
String.format(MESSAGE_INVALID_COMMAND_FORMAT, TagFindCommand.MESSAGE_USAGE)); | ||
} | ||
TagMatchingKeywordPredicate predicate = new TagMatchingKeywordPredicate(trimmedArgs); | ||
return new TagFindCommand(predicate); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.