Skip to content

Commit

Permalink
Rename showfav to listfav
Browse files Browse the repository at this point in the history
  • Loading branch information
sun-ruiheng committed Apr 10, 2024
1 parent 7143363 commit 30a45a4
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 82 deletions.
75 changes: 46 additions & 29 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ GourmetGrid User Guide
- Listing all contacts : list
- Editing a contact : edit
- Adding contacts as favourites : addfav
- Showing favourite contacts : showfav
- Showing favourite contacts : listfav
- Removing contacts from favourites : removefav
- Searching contact : find
- Adding an order : addorder
Expand Down Expand Up @@ -155,8 +155,9 @@ Examples:
Shows a list of all contacts in the address book.

Format: `list`
<box type="tip" seamless>

**Note:** `list` command is not compatible with further arguments.
**Reminder:** `list` command is not compatible with further arguments.
</box>

### Editing a contact : `edit`
Expand All @@ -170,14 +171,15 @@ Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [c/COMPANY] [t/TAG]
* Existing values will be updated to the input values.
* You can remove all the contact’s tags by typing `t/` without
specifying any tags after it.
* **Warning**: Making any edit to tags will replace all existing tags with the new tags.

Examples:
* `edit 1 p/91234567 e/[email protected]` Edits the phone number and email address of the 1st contact to be `91234567` and `[email protected]` respectively.
* `edit 2 n/Betsy Crower t/` Edits the name of the 2nd contact to be `Betsy Crower` and clears all existing tags.

### Adding contacts as favourites : `addfav`

- Adds the contacts specified by index as favourites
Adds the contacts specified by index as favourites

Format: `addfav i/INDICES`
- Adds the contacts at the specified `INDICES` as favourites. The indices refer to comma-separated index numbers (i.e. index, index, index) shown in the displayed contact list. Each index **must be a positive integer** 1,2,3, ...
Expand All @@ -193,19 +195,21 @@ Examples:
- `addfav` returns an error message as it must be accompanied by the 'INDICES' field
- `addfav 1 i/ 2, 5` returns an error message as there should not be prefixes before the 'INDICES' field
-
### Showing favourite contacts : `showfav`
### Showing favourite contacts : `listfav`

Lists the contacts that are marked as favourites

- Shows the contacts that are marked as favourites
Format: `listfav`

Format: `showfav`
<box type="tip" seamless>

**Note:** `showfav` command is not compatible with further arguments.
**Reminder:** `listfav` command is not compatible with further arguments.
</box>

Examples:
- `showfav` Shows all favourited contacts as expected
- `showfav 1` returns an error message as there should not be arguments after the `showfav` command word
- `showfav hello` returns an error message as there should not be arguments after the `showfav` command word
- `listfav` Lists all favourited contacts as expected
- `listfav 1` returns an error message as there should not be arguments after the `listfav` command word
- `listfav hello` returns an error message as there should not be arguments after the `listfav` command word

### Removing contacts from favourites : `removefav`

Expand All @@ -226,11 +230,9 @@ Examples:

### Searching Contact : `find`

- Search feature supports substring search by name and/or tags and/or company **ONLY**.
- Finds all contacts whose names, tags or company matches the substring keyword provided.

Search feature supports substring search by name and/or tags and/or company **ONLY**. Finds all contacts whose names, tags or company matches the substring keyword provided.

General Format: `find FIELD/ KEYWORD FIELD/ KEYWORD ...`
Format: `find FIELD/KEYWORD [FIELD/KEYWORD]...`
- Where `FIELD` is either `n/` for name or `t/` for tag or `c/` for company.
- `KEYWORD` is the keyword to search for, here are some guidelines:
- Name and Company should contain alphanumeric characters, spaces, hyphens and/or apostrophes only.
Expand Down Expand Up @@ -353,12 +355,22 @@ Clears all entries from the address book.

Format: `clear`

<box type="tip" seamless>

**Reminder:** `clear` command is not compatible with further arguments.
</box>

### Exiting the program : `exit`

Exits the program.

Format: `exit`

<box type="tip" seamless>

**Reminder:** `exit` command is not compatible with further arguments.
</box>

### Viewing help : `help`

Shows a message explaining how to access the help page.
Expand All @@ -367,6 +379,11 @@ Shows a message explaining how to access the help page.

Format: `help`

<box type="tip" seamless>

**Reminder:** `help` command is not compatible with further arguments.
</box>

### Saving the data

GourmetGrid data are saved in the hard disk automatically after any command that changes the data. There is no need to save manually.
Expand Down Expand Up @@ -401,20 +418,20 @@ Furthermore, certain edits can cause GourmetGrid to behave in unexpected ways (e

## Command summary

| Action | Format, Examples |
|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Action | Format, Examples |
|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Add** | `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS c/COMPANY [t/TAG]…​` <br> e.g., `add n/James Ho p/22224444 e/[email protected] a/123, Clementi Rd, 1234665 c/Freshest Farm t/friend t/colleague` |
| **Clear** | `clear` |
| **Delete** | `delete INDEX`<br> e.g., `delete 3` |
| **Edit** | `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [c/COMPANY] [t/TAG]…​`<br> e.g.,`edit 2 n/James Lee e/[email protected]` |
| **Find** | `find KEYWORD/ [KEYWORD]`<br> e.g., `find n/ James n/ T t/ friend t/ rich` |
| **Add Order** | `addorder INDEX d/DATE r/REMARK`<br> e.g., `addorder 1 d/ 2020-01-01 r/ 100 chicken wings` |
| **List Orders** | `listorder INDEX` |
| **Delete Order** | `deleteorder INDEX o/ORDER_INDEX`<br> e.g., `deleteorder 2 o/1` |
| **Add Favourite** | `addfav i/INDICES`<br> e.g., `addfav i/1,2` |
| **Show Favourites** | `showfav` |
| **Remove Favourite** | `removefav i/INDICES`<br> e.g., `removefav i/2` |
| **List** | `list` |
| **Help** | `help` |
| **Exit** | `exit` |
| **Clear** | `clear` |
| **Delete** | `delete INDEX`<br> e.g., `delete 3` |
| **Edit** | `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [c/COMPANY] [t/TAG]…​`<br> e.g.,`edit 2 n/James Lee e/[email protected]` |
| **Find** | `find KEYWORD/ [KEYWORD]`<br> e.g., `find n/ James n/ T t/ friend t/ rich` |
| **Add Order** | `addorder INDEX d/DATE r/REMARK`<br> e.g., `addorder 1 d/ 2020-01-01 r/ 100 chicken wings` |
| **List Orders** | `listorder INDEX` |
| **Delete Order** | `deleteorder INDEX o/ORDER_INDEX`<br> e.g., `deleteorder 2 o/1` |
| **Add Favourite** | `addfav i/INDICES`<br> e.g., `addfav i/1,2` |
| **Show Favourites** | `listfav` |
| **Remove Favourite** | `removefav i/INDICES`<br> e.g., `removefav i/2` |
| **List** | `list` |
| **Help** | `help` |
| **Exit** | `exit` |

54 changes: 27 additions & 27 deletions docs/diagrams/ShowFavouriteSequenceDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ skinparam ArrowFontStyle plain
box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR
participant ":ShowFavouriteCommandParser" as ShowFavouriteCommandParser LOGIC_COLOR
participant "s:ShowFavouriteCommand" as ShowFavouriteCommand LOGIC_COLOR
participant ":ListFavouriteCommandParser" as ListFavouriteCommandParser LOGIC_COLOR
participant "l:ListFavouriteCommand" as ListFavouriteCommand LOGIC_COLOR
participant "r:CommandResult" as CommandResult LOGIC_COLOR
end box

Expand All @@ -25,36 +25,36 @@ activate LogicManager
LogicManager -> AddressBookParser : parseCommand(args)
activate AddressBookParser

create ShowFavouriteCommandParser
AddressBookParser -> ShowFavouriteCommandParser
activate ShowFavouriteCommandParser
create ListFavouriteCommandParser
AddressBookParser -> ListFavouriteCommandParser
activate ListFavouriteCommandParser

ShowFavouriteCommandParser --> AddressBookParser
deactivate ShowFavouriteCommandParser
ListFavouriteCommandParser --> AddressBookParser
deactivate ListFavouriteCommandParser

AddressBookParser -> ShowFavouriteCommandParser : parse(args)
activate ShowFavouriteCommandParser
AddressBookParser -> ListFavouriteCommandParser : parse(args)
activate ListFavouriteCommandParser

create ShowFavouriteCommand
ShowFavouriteCommandParser -> ShowFavouriteCommand
activate ShowFavouriteCommand
create ListFavouriteCommand
ListFavouriteCommandParser -> ListFavouriteCommand
activate ListFavouriteCommand

ShowFavouriteCommand --> ShowFavouriteCommandParser :
deactivate ShowFavouriteCommand
ListFavouriteCommand --> ListFavouriteCommandParser :
deactivate ListFavouriteCommand

ShowFavouriteCommandParser --> AddressBookParser : s
deactivate ShowFavouriteCommandParser
ListFavouriteCommandParser --> AddressBookParser : l
deactivate ListFavouriteCommandParser
'Hidden arrow to position the destroy marker below the end of the activation bar.
ShowFavouriteCommandParser -[hidden]-> AddressBookParser
destroy ShowFavouriteCommandParser
ListFavouriteCommandParser -[hidden]-> AddressBookParser
destroy ListFavouriteCommandParser

AddressBookParser --> LogicManager : s
AddressBookParser --> LogicManager : l
deactivate AddressBookParser

LogicManager -> ShowFavouriteCommand : execute(m)
activate ShowFavouriteCommand
LogicManager -> ListFavouriteCommand : execute(m)
activate ListFavouriteCommand

ShowFavouriteCommand -> Model : updateFilteredPersonList(pred)
ListFavouriteCommand -> Model : updateFilteredPersonList(pred)
activate Model

Model -> FilteredList : setPredicate(pred)
Expand All @@ -63,16 +63,16 @@ activate FilteredList
FilteredList --> Model
deactivate FilteredList

Model --> ShowFavouriteCommand
Model --> ListFavouriteCommand
deactivate Model

ShowFavouriteCommand -> CommandResult
ListFavouriteCommand -> CommandResult
activate CommandResult
CommandResult --> ShowFavouriteCommand
CommandResult --> ListFavouriteCommand
deactivate CommandResult

ShowFavouriteCommand --> LogicManager : r
deactivate ShowFavouriteCommand
ListFavouriteCommand --> LogicManager : r
deactivate ListFavouriteCommand

[<-- LogicManager : r
deactivate LogicManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
/**
* Lists all favourites in the address book to the user.
*/
public class ShowFavouriteCommand extends Command {
public class ListFavouriteCommand extends Command {

public static final String COMMAND_WORD = "showfav";
public static final String COMMAND_WORD = "listfav";

public static final String MESSAGE_SUCCESS = "Displayed all favourites";

Expand All @@ -30,6 +30,6 @@ public boolean equals(Object other) {
}

// instanceof handles nulls
return other instanceof ShowFavouriteCommand;
return other instanceof ListFavouriteCommand;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import seedu.address.logic.commands.FindCommand;
import seedu.address.logic.commands.HelpCommand;
import seedu.address.logic.commands.ListCommand;
import seedu.address.logic.commands.ListFavouriteCommand;
import seedu.address.logic.commands.ListOrderCommand;
import seedu.address.logic.commands.RemoveFavouriteCommand;
import seedu.address.logic.commands.ShowFavouriteCommand;
import seedu.address.logic.parser.exceptions.ParseException;

/**
Expand Down Expand Up @@ -98,8 +98,8 @@ public Command parseCommand(String userInput) throws ParseException {
case HelpCommand.COMMAND_WORD:
return new HelpCommandParser().parse(arguments);

case ShowFavouriteCommand.COMMAND_WORD:
return new ShowFavouriteCommandParser().parse(arguments);
case ListFavouriteCommand.COMMAND_WORD:
return new ListFavouriteCommandParser().parse(arguments);

default:
logger.finer("This user input caused a ParseException: " + userInput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

import static seedu.address.logic.parser.ParserUtil.parseNoArgs;

import seedu.address.logic.commands.ShowFavouriteCommand;
import seedu.address.logic.commands.ListFavouriteCommand;
import seedu.address.logic.parser.exceptions.ParseException;

/**
* Parses input arguments and creates a new ShowFavouriteCommand object
*/
public class ShowFavouriteCommandParser implements Parser<ShowFavouriteCommand> {
public class ListFavouriteCommandParser implements Parser<ListFavouriteCommand> {

/**
* Parses any potential {@code String} of text in the context of the ShowFavouriteCommand that should not be there,
* and returns an AddCommand object for execution.
* @throws ParseException if the user input has any text after the command word
*/
public ShowFavouriteCommand parse(String args) throws ParseException {
public ListFavouriteCommand parse(String args) throws ParseException {
parseNoArgs(args);
return new ShowFavouriteCommand();
return new ListFavouriteCommand();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,38 @@
/**
* Contains integration tests (interaction with the Model) and unit tests for ShowFavouriteCommand.
*/
public class ShowFavouriteCommandTest {
public class ListFavouriteCommandTest {

@Test
public void execute_showFavouriteWithFavourites_success() {
public void execute_listFavouriteWithFavourites_success() {
Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
ShowFavouriteCommand showFavouriteCommand = new ShowFavouriteCommand();
ListFavouriteCommand listFavouriteCommand = new ListFavouriteCommand();

String expectedMessage = ShowFavouriteCommand.MESSAGE_SUCCESS;
String expectedMessage = ListFavouriteCommand.MESSAGE_SUCCESS;
Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs());

model.setPerson(ALICE, new PersonBuilder(ALICE).withFavourite(true).build());

expectedModel.updateFilteredPersonList(person -> person.isSamePerson(ALICE)); // only Alice is favourited
model.updateFilteredPersonList(Model.PREDICATE_SHOW_FAVOURITES);
assertCommandSuccess(showFavouriteCommand, model, expectedMessage, expectedModel);
assertCommandSuccess(listFavouriteCommand, model, expectedMessage, expectedModel);
}

@Test
public void equals() {
ShowFavouriteCommand showFavouriteCommand = new ShowFavouriteCommand();
ListFavouriteCommand listFavouriteCommand = new ListFavouriteCommand();

// same object -> returns true
assert (showFavouriteCommand.equals(showFavouriteCommand));
assert (listFavouriteCommand.equals(listFavouriteCommand));

// same values -> returns true
ShowFavouriteCommand showFavouriteCommandCopy = new ShowFavouriteCommand();
assert (showFavouriteCommand.equals(showFavouriteCommandCopy));
ListFavouriteCommand listFavouriteCommandCopy = new ListFavouriteCommand();
assert (listFavouriteCommand.equals(listFavouriteCommandCopy));

// different types -> returns false
assertFalse(showFavouriteCommand.equals(1));
assertFalse(listFavouriteCommand.equals(1));

// null -> returns false
assertFalse(showFavouriteCommand.equals(null));
assertFalse(listFavouriteCommand.equals(null));
}
}
Loading

0 comments on commit 30a45a4

Please sign in to comment.