Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #149 from Cloud7050/msg
Browse files Browse the repository at this point in the history
Update samples, docs, command usage, display format
  • Loading branch information
bwangpj authored Nov 3, 2023
2 parents fa840db + 3ec8d2a commit 5c04f67
Show file tree
Hide file tree
Showing 29 changed files with 224 additions and 149 deletions.
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ application {
mainClass = 'swe.context.Main'
}

clean {
delete './data/'
delete './settings.json'
delete fileTree('./') { include '*.log.*' }
}

run {
enableAssertions true
}
Expand Down
4 changes: 2 additions & 2 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ The following activity diagram summarises what happens when a user executes an e

- Can type fast and prefer typing
- Are reasonably comfortable with command-line inputs
- Wish to label contacts by category (e.g. professors, classmates from certain courses)
- Have many different ways to reach their contacts (e.g. local/overseas phone number, Telegram, Discord etc.)
- Wish to label contacts by category (e.g. professors, classmates from certain courses, friends)
- Have many different ways to reach their contacts (e.g. social media like Telegram/Discord, additional phone numbers like house phone)

**Value proposition**: Manage contacts quickly via text commands, with useful features relevant to SoC students.

Expand Down
23 changes: 12 additions & 11 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ It is optimized for use via an in-app Command Line Interface (CLI), while still

It has useful features relevant to NUS SoC students:

- Tagging contacts by category: You can tag your professors and classmates with custom tags such as "Professor", "Tutorial mate", "CS2103" etc., then filter by tag to view all contacts with a certain tag.
- Storing different ways to reach people: By adding alternate contact details, you could have local phone number, overseas phone number, Telegram, Discord etc. all in the same contact.
- Works like a usual CLI: You can use the up/down arrow keys to switch between previously-entered commands, making entering and repeating commands (e.g. adding many new contacts) easier.
- Tagging contacts by category: You can tag your professors and classmates with custom tags such as "prof", "friend", "CS2103 course" etc., then filter by tag to view all contacts with a certain tag.
- Storing different ways to reach people: By adding alternate contact details, you could have Telegram, Discord, mobile phone, house phone etc. all in the same contact.
- Works like a usual CLI: You can use the up/down arrow keys to switch between previously-entered commands, making entering and repeating commands (e.g. adding many new contacts) easier.

If you can type fast, prefer typing, and are reasonably comfortable with CLI inputs, ConText can let you manage contacts faster than traditional GUI apps.

Expand Down Expand Up @@ -78,8 +78,8 @@ Adds a new contact.
Note that contacts are identified by their name in ConText, and contacts with exactly the same name (including casing) are considered the same contact.
Hence, you will not be able to add a new contact with the same name as an existing contact.

For example, if you already have a contact with name "John Doe", you will not be able to add another contact with the same name "John Doe".
However, you may add another contact with name "John Alex Doe", or "John doe", or you may first modify the name of the existing contact.
For example, if you already have a contact with name `John Doe`, you will not be able to add another contact with the same name `John Doe`.
However, you may add another contact with name `John doe`, or `Alex John Doe`. You may also first modify the name of the existing contact.

Should you need to make changes to an existing contact, use the `edit` command as explained below.

Expand All @@ -99,7 +99,7 @@ The format for `ALTERNATE_CONTACT` is `TYPE: USERNAME`, roughly looking like `So
**Examples:**

- `add n/John Doe p/98765432 e/[email protected]`
- `add n/John Doe p/98765432 e/[email protected] o/Good at SE. t/NUS t/CS2103 course a/Telegram: JohnDoe`
- `add n/John Doe p/98765432 e/[email protected] o/Likes SE. t/NUS t/CS2103 course a/Telegram: JohnDoe`

### Editing a contact: `edit`

Expand Down Expand Up @@ -199,18 +199,19 @@ e.g. `find Bee John` will match the names `Amy Bee` and `John Doe`.
**Examples:**

- `find John`
- `find alex Bernice CHARLOTTE`
- `find amy Ben CHARLOTTE`

### Filtering by tag: `filter`

Search and display contacts with tag matching the given keywords (case-insensitive).
Shows contacts with a tag that fully matches the specified tag (case-insensitive).

**Format:**
`filter [KEYWORDS]`
`filter TAG`

**Example:**
**Examples:**

- `filter Friend`
- `filter NUS`
- `filter CS2103 course`

### Viewing help: `help`

Expand Down
File renamed without changes.
Binary file modified docs/images/Ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions src/main/java/swe/context/commons/util/StringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import java.io.StringWriter;
import java.util.Arrays;

import swe.context.logic.Messages;

/**
* Helper functions for handling strings.
*/
public class StringUtil {
public static final String MESSAGE_KEYWORD_EMPTY = "Keyword cannot be empty.";
public static final String MESSAGE_KEYWORD_MULTI_WORD = "Keyword should be a single word.";

/**
* Returns true if the {@code sentence} contains the {@code word}.
Expand All @@ -30,8 +30,8 @@ public static boolean containsWordIgnoreCase(String sentence, String word) {
requireNonNull(word);

String preppedWord = word.trim();
checkArgument(!preppedWord.isEmpty(), Messages.EMPTY_WORD_PARAMETER);
checkArgument(preppedWord.split("\\s+").length == 1, Messages.SINGLE_WORD_EXPECTED);
checkArgument(!preppedWord.isEmpty(), StringUtil.MESSAGE_KEYWORD_EMPTY);
checkArgument(preppedWord.split("\\s+").length == 1, StringUtil.MESSAGE_KEYWORD_MULTI_WORD);

String preppedSentence = sentence;
String[] wordsInPreppedSentence = preppedSentence.split("\\s+");
Expand Down
65 changes: 37 additions & 28 deletions src/main/java/swe/context/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,47 @@
*/
public final class Messages {
// Generic commands
public static final String COMMAND_UNKNOWN = "Unknown command.";
public static final String DUPLICATE_FIELDS =
"Multiple values specified for the following single-valued field(s): ";
public static final String EMPTY_WORD_PARAMETER = "Word parameter cannot be empty";
public static final String SINGLE_WORD_EXPECTED = "Word parameter should be a single word";
public static final String COMMAND_DUPLICATE_CONTACT = "This contact is already in your contact list.";
public static final String EDIT_COMMAND_NOT_EDITED = "At least one field to edit must be provided.";
public static final String HELP_COMMAND_SHOW_HELP = "Opened help window.";
public static final String LIST_COMMAND_SUCCESS = "Listed all contacts";
private static final String UNFORMATTED_COMMAND_INVALID_FORMAT = "Invalid command format.\n%s";
private static final String UNFORMATTED_CONTACTS_LISTED_OVERVIEW = "%d contacts listed!";
private static final String UNFORMATTED_ADD_COMMAND_SUCCESS = "New contact added: %1$s";
private static final String UNFORMATTED_DELETE_COMMAND_SUCCESS = "Deleted Contact(s): \n%1$s";
private static final String UNFORMATTED_EDIT_COMMAND_SUCCESS = "Edited Contact: %1$s";
"Multiple values specified for the following single-valued parameters(s): ";
public static final String COMMAND_DUPLICATE_CONTACT =
"There is an existing contact with the same name.";
private static final String UNFORMATTED_COMMAND_INVALID_FORMAT = "Invalid command format.%n%s";
private static final String UNFORMATTED_COMMAND_UNKNOWN = "Unknown command.%n%s";
private static final String UNFORMATTED_CONTACTS_LISTED_OVERVIEW = "%d contacts listed.";
private static final String UNFORMATTED_ADD_COMMAND_SUCCESS = "New contact added: %s";
private static final String UNFORMATTED_DELETE_COMMAND_SUCCESS = "Deleted contact(s):%n%s";
private static final String UNFORMATTED_EDIT_COMMAND_SUCCESS = "Edited contact: %s";

// Specific commands
public static final String COMMAND_CLEAR_SUCCESS = "All contacts have been removed!";
public static final String COMMAND_EDIT_NO_PARAM =
"At least one optional parameter to edit must be provided.";
public static final String COMMAND_CLEAR_SUCCESS = "Removed all contacts!";
public static final String COMMAND_LIST_SUCCESS = "Listed all contacts.";
public static final String COMMAND_HELP_SUCCESS = "Opened help window.";
public static final String COMMAND_EXIT_SUCCESS = "Exiting app...";

public static final String INVALID_DELETE_INDEX =
"One or more of the contact indices provided are invalid";
public static final String INVALID_EDIT_INDEX = "The contact index provided is invalid";
public static final String INVALID_PARSER_INDEX = "Index is not a non-zero unsigned integer.";

// Contacts
// Messages associated with Attributes constraints
public static final String NAME_INVALID =
"Names must be alphanumeric (spaces allowed).";
public static final String PHONE_INVALID =
"Phone numbers must start with at least 3 digits.";
"One or more of the contact indices provided are invalid.";
public static final String INVALID_EDIT_INDEX = "The contact index provided is invalid.";

// Validation messages for command parameter constraints
public static final String NAME_INVALID = "Names must be alphanumeric (spaces allowed).";
public static final String PHONE_INVALID = "Phone numbers must start with at least 3 digits.";
public static final String EMAIL_INVALID =
"Emails must roughly be of the form \"[email protected].\"";
private static final String UNFORMATTED_TAG_INVALID =
"\"%s\" is not a valid tag. Tags must be alphanumeric (spaces allowed).";

private static final String UNFORMATTED_ALTERNATECONTACT_INVALID =
"\"%s\" is not a valid alternate contact. "
+ "Alternate contacts must roughly be of the form \"socialMedia: name\"";
+ "Alternate contacts must roughly be of the form \"SocialMedia: Username\"";

// JSON
public static final String CONVERT_CONTACTS_DUPLICATE = "Encountered duplicate while converting contacts.";
public static final String CONVERT_CONTACTS_DUPLICATE =
"Encountered duplicate while converting contacts.";

// Exceptions
public static final String DUPLICATE_CONTACT_EXCEPTION = "Operation would result in duplicate contacts";
public static final String DUPLICATE_CONTACT_EXCEPTION =
"Operation would result in duplicate contacts";
private static final String UNFORMATTED_FILE_OPS_ERROR_FORMAT =
"Could not save data due to the following error: %s";
private static final String UNFORMATTED_FILE_OPS_PERMISSION_ERROR_FORMAT =
Expand All @@ -72,6 +70,17 @@ public static String commandInvalidFormat(String helpText) {
);
}

/**
* Returns a formatted message about the command being unknown, with the
* specified help text.
*/
public static String commandUnknown(String helpText) {
return String.format(
Messages.UNFORMATTED_COMMAND_UNKNOWN,
helpText
);
}

/**
* Returns a formatted message about the specified tag name being invalid.
*/
Expand Down
38 changes: 22 additions & 16 deletions src/main/java/swe/context/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,28 @@
public class AddCommand extends Command {
public static final String COMMAND_WORD = "add";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a contact. "
+ "Parameters: "
+ PREFIX_NAME + "NAME "
+ PREFIX_PHONE + "PHONE "
+ PREFIX_EMAIL + "EMAIL "
+ "[" + PREFIX_NOTE + "NOTE] "
+ "[" + PREFIX_TAG + "TAG]... "
+ "[" + PREFIX_ALTERNATE + "ALTERNATE CONTACTS]...\n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_NAME + "John Doe "
+ PREFIX_PHONE + "98765432 "
+ PREFIX_EMAIL + "[email protected] "
+ PREFIX_NOTE + "CS2103 Prof. "
+ PREFIX_TAG + "NUS "
+ PREFIX_TAG + "CS2103 course "
+ PREFIX_ALTERNATE + "Telegram@JohnDoe";
public static final String MESSAGE_USAGE = String.format(
"%s: Adds a contact."
+ "%nParameters: %sNAME %sPHONE_NUMBER %sEMAIL"
+ " [%sNOTE] [%sTAG]... [%sALTERNATE_CONTACT]..."
+ "%nExample: %s %sJohn Doe %s98765432 %[email protected]"
+ " %sLikes SE. %sNUS %sCS2103 course %sTelegram: JohnDoe",
AddCommand.COMMAND_WORD,
PREFIX_NAME,
PREFIX_PHONE,
PREFIX_EMAIL,
PREFIX_NOTE,
PREFIX_TAG,
PREFIX_ALTERNATE,
AddCommand.COMMAND_WORD,
PREFIX_NAME,
PREFIX_PHONE,
PREFIX_EMAIL,
PREFIX_NOTE,
PREFIX_TAG,
PREFIX_TAG,
PREFIX_ALTERNATE
);

private final Contact toAdd;
/**
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/swe/context/logic/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@
import swe.context.model.Model;
import swe.context.model.contact.Contact;



/**
* Deletes one or more {@link Contact}s based on their displayed indices in the UI list.
* Duplicate indices are considered only once.
*/
public class DeleteCommand extends Command {

public static final String COMMAND_WORD = "delete";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Deletes the contacts identified by the index number(s) used in the displayed contact list.\n"
+ "Parameters: INDEX_1 INDEX_2 ... (must be 1 or more positive integers)\n"
+ "Example: " + COMMAND_WORD + " 1 3 5";
public static final String MESSAGE_USAGE = String.format(
"%s: Deletes contact(s)."
+ "%nParameters: INDEX..."
+ "%nExample: %s 1 3 5",
DeleteCommand.COMMAND_WORD,
DeleteCommand.COMMAND_WORD
);

private final List<Index> targetIndices;

Expand Down
33 changes: 18 additions & 15 deletions src/main/java/swe/context/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,30 @@
import swe.context.model.contact.Phone;
import swe.context.model.tag.Tag;



/**
* Edits an existing {@link Contact}.
*/
public class EditCommand extends Command {

public static final String COMMAND_WORD = "edit";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Edits the details of the contact identified "
+ "by the index number used in the displayed contact list. "
+ "Existing values will be overwritten by the input values.\n"
+ "Parameters: INDEX (must be a positive integer) "
+ "[" + PREFIX_NAME + "NAME] "
+ "[" + PREFIX_PHONE + "PHONE] "
+ "[" + PREFIX_EMAIL + "EMAIL] "
+ "[" + PREFIX_NOTE + "NOTE] "
+ "[" + PREFIX_TAG + "TAG]... "
+ "[" + PREFIX_ALTERNATE + "ALTERNATE CONTACT]...\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_PHONE + "91234567 "
+ PREFIX_EMAIL + "[email protected]";
public static final String MESSAGE_USAGE = String.format(
"%s: Edits a contact. At least one optional parameter required."
+ "%nParameters: INDEX [%sNAME] [%sPHONE_NUMBER] [%sEMAIL]"
+ " [%sNOTE] [%sTAG]... [%sALTERNATE_CONTACT]..."
+ "%nExample: %s 3 %sMember of NUS S/U %s",
EditCommand.COMMAND_WORD,
PREFIX_NAME,
PREFIX_PHONE,
PREFIX_EMAIL,
PREFIX_NOTE,
PREFIX_TAG,
PREFIX_ALTERNATE,
EditCommand.COMMAND_WORD,
PREFIX_NOTE,
PREFIX_TAG
);

private final Index index;
private final EditContactDescriptor editContactDescriptor;
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/swe/context/logic/commands/FilterCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
public class FilterCommand extends Command {
public static final String COMMAND_WORD = "filter";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Filters and lists all contacts whose tags match the"
+ " specified tag in full. Case insensitive."
+ "\nParameters: TAG"
+ "\nExample: " + COMMAND_WORD + " Friend";
public static final String MESSAGE_USAGE = String.format(
"%s: Filters contacts by tag. Case insensitive. Requires full tag match."
+ "%nParameters: TAG"
+ "%nExample: %s CS2103 course",
FilterCommand.COMMAND_WORD,
FilterCommand.COMMAND_WORD
);

private final ContainsTagPredicate predicate;

Expand Down
12 changes: 7 additions & 5 deletions src/main/java/swe/context/logic/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
public class FindCommand extends Command {
public static final String COMMAND_WORD = "find";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Finds and lists all contacts whose names match any of the"
+ " specified words in full. Case insensitive."
+ "\nParameters: [KEYWORD]..."
+ "\nExample: " + COMMAND_WORD + " alice bob charlie";
public static final String MESSAGE_USAGE = String.format(
"%s: Finds contacts by name. Case insensitive. Requires full word match."
+ "%nParameters: KEYWORD..."
+ "%nExample: %s amy Ben CHARLOTTE",
FindCommand.COMMAND_WORD,
FindCommand.COMMAND_WORD
);

private final NameContainsKeywordsPredicate predicate;

Expand Down
11 changes: 7 additions & 4 deletions src/main/java/swe/context/logic/commands/HelpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@
import swe.context.logic.Messages;
import swe.context.model.Model;



/**
* Format full help instructions for every command for display.
*/
public class HelpCommand extends Command {

public static final String COMMAND_WORD = "help";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Shows program usage instructions.\n"
+ "Example: " + COMMAND_WORD;
public static final String MESSAGE_USAGE = String.format(
"%s: Opens the help window.",
HelpCommand.COMMAND_WORD
);

@Override
public CommandResult execute(Model model) {
return new CommandResult(Messages.HELP_COMMAND_SHOW_HELP, true, false);
return new CommandResult(Messages.COMMAND_HELP_SUCCESS, true, false);
}
}
Loading

0 comments on commit 5c04f67

Please sign in to comment.