Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[W5][T12-1] Zhang Shaoqian #175

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ hs_err_pid*
.idea/
*.iml

# VS Code files
.vscode/

# Temp files used for testing
test/actual.txt
test/localrun.bat
Expand Down
5 changes: 3 additions & 2 deletions src/seedu/addressbook/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import seedu.addressbook.data.person.ReadOnlyPerson;
import seedu.addressbook.data.person.UniquePersonList;
import seedu.addressbook.data.tag.Tag;
import static seedu.addressbook.ui.TextUi.INDENT_1;

/**
* Adds a person to the address book.
Expand All @@ -22,8 +23,8 @@ public class AddCommand extends Command {

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. "
+ "Contact details can be marked private by prepending 'p' to the prefix.\n"
+ "Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...\n"
+ "Example: " + COMMAND_WORD
+ INDENT_1 + "Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...\n"
+ INDENT_1 + "Example: " + COMMAND_WORD
+ " John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney";

public static final String MESSAGE_SUCCESS = "New person added: %1$s";
Expand Down
6 changes: 4 additions & 2 deletions src/seedu/addressbook/commands/ClearCommand.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package seedu.addressbook.commands;

import static seedu.addressbook.ui.TextUi.INDENT_1;

/**
* Clears the address book.
*/
public class ClearCommand extends Command {

public static final String COMMAND_WORD = "clear";
public static final String MESSAGE_USAGE = "Clears address book permanently.\n"
+ "Example: " + COMMAND_WORD;
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Clears address book permanently.\n"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is a (intended?) bug actually. Good job spotting it!

+ INDENT_1 + "Example: " + COMMAND_WORD;

public static final String MESSAGE_SUCCESS = "Address book has been cleared!";

Expand Down
5 changes: 3 additions & 2 deletions src/seedu/addressbook/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import seedu.addressbook.common.Messages;
import seedu.addressbook.data.person.ReadOnlyPerson;
import seedu.addressbook.data.person.UniquePersonList.PersonNotFoundException;
import static seedu.addressbook.ui.TextUi.INDENT_1;


/**
Expand All @@ -14,8 +15,8 @@ public class DeleteCommand extends Command {

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Deletes the person identified by the index number used in the last person listing.\n"
+ "Parameters: INDEX\n"
+ "Example: " + COMMAND_WORD + " 1";
+ INDENT_1 + "Parameters: INDEX\n"
+ INDENT_1 + "Example: " + COMMAND_WORD + " 1";

public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Person: %1$s";

Expand Down
4 changes: 3 additions & 1 deletion src/seedu/addressbook/commands/ExitCommand.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package seedu.addressbook.commands;

import static seedu.addressbook.ui.TextUi.INDENT_1;

/**
* Terminates the program.
*/
Expand All @@ -8,7 +10,7 @@ public class ExitCommand extends Command {
public static final String COMMAND_WORD = "exit";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Exits the program.\n"
+ "Example: " + COMMAND_WORD;
+ INDENT_1 + "Example: " + COMMAND_WORD;
public static final String MESSAGE_EXIT_ACKNOWEDGEMENT = "Exiting Address Book as requested ...";

@Override
Expand Down
5 changes: 3 additions & 2 deletions src/seedu/addressbook/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Set;

import seedu.addressbook.data.person.ReadOnlyPerson;
import static seedu.addressbook.ui.TextUi.INDENT_1;

/**
* Finds and lists all persons in address book whose name contains any of the argument keywords.
Expand All @@ -18,8 +19,8 @@ public class FindCommand extends Command {

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of "
+ "the specified keywords (case-sensitive) and displays them as a list with index numbers.\n"
+ "Parameters: KEYWORD [MORE_KEYWORDS]...\n"
+ "Example: " + COMMAND_WORD + " alice bob charlie";
+ INDENT_1 + "Parameters: KEYWORD [MORE_KEYWORDS]...\n"
+ INDENT_1 + "Example: " + COMMAND_WORD + " alice bob charlie";

private final Set<String> keywords;

Expand Down
3 changes: 2 additions & 1 deletion src/seedu/addressbook/commands/HelpCommand.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package seedu.addressbook.commands;

import static seedu.addressbook.ui.TextUi.INDENT_1;

/**
* Shows help instructions.
Expand All @@ -9,7 +10,7 @@ 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;
+ INDENT_1 + "Example: " + COMMAND_WORD;

@Override
public CommandResult execute() {
Expand Down
3 changes: 2 additions & 1 deletion src/seedu/addressbook/commands/ListCommand.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seedu.addressbook.commands;

import seedu.addressbook.data.person.ReadOnlyPerson;
import static seedu.addressbook.ui.TextUi.INDENT_1;

import java.util.List;

Expand All @@ -14,7 +15,7 @@ public class ListCommand extends Command {

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Displays all persons in the address book as a list with index numbers.\n"
+ "Example: " + COMMAND_WORD;
+ INDENT_1 + "Example: " + COMMAND_WORD;


@Override
Expand Down
5 changes: 3 additions & 2 deletions src/seedu/addressbook/commands/ViewAllCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import seedu.addressbook.common.Messages;
import seedu.addressbook.data.person.ReadOnlyPerson;
import static seedu.addressbook.ui.TextUi.INDENT_1;


/**
Expand All @@ -14,8 +15,8 @@ public class ViewAllCommand extends Command {

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Views the non-private details of the person "
+ "identified by the index number in the last shown person listing.\n"
+ "Parameters: INDEX\n"
+ "Example: " + COMMAND_WORD + " 1";
+ INDENT_1 + "Parameters: INDEX\n"
+ INDENT_1 + "Example: " + COMMAND_WORD + " 1";

public static final String MESSAGE_VIEW_PERSON_DETAILS = "Viewing person: %1$s";

Expand Down
5 changes: 3 additions & 2 deletions src/seedu/addressbook/commands/ViewCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import seedu.addressbook.common.Messages;
import seedu.addressbook.data.person.ReadOnlyPerson;
import static seedu.addressbook.ui.TextUi.INDENT_1;


/**
Expand All @@ -14,8 +15,8 @@ public class ViewCommand extends Command {

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Views the non-private details of the person "
+ "identified by the index number in the last shown person listing.\n"
+ "Parameters: INDEX\n"
+ "Example: " + COMMAND_WORD + " 1";
+ INDENT_1 + "Parameters: INDEX\n"
+ INDENT_1 + "Example: " + COMMAND_WORD + " 1";

public static final String MESSAGE_VIEW_PERSON_DETAILS = "Viewing person: %1$s";

Expand Down
2 changes: 2 additions & 0 deletions src/seedu/addressbook/ui/TextUi.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class TextUi {
/** Format of indexed list item */
private static final String MESSAGE_INDEXED_LIST_ITEM = "\t%1$d. %2$s";

/** One level of indent for pretty printing */
public static final String INDENT_1 = " ";

/** Offset required to convert between 1-indexing and 0-indexing. */
public static final int DISPLAYED_INDEX_OFFSET = 1;
Expand Down
62 changes: 31 additions & 31 deletions test/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@
|| ===================================================
|| Enter command: || [Command entered: sfdfd]
|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix.
|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...
|| Example: add John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney
|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...
|| Example: add John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney
|| delete: Deletes the person identified by the index number used in the last person listing.
|| Parameters: INDEX
|| Example: delete 1
|| Clears address book permanently.
|| Example: clear
|| Parameters: INDEX
|| Example: delete 1
|| clear: Clears address book permanently.
|| Example: clear
|| find: Finds all persons whose names contain any of the specified keywords (case-sensitive) and displays them as a list with index numbers.
|| Parameters: KEYWORD [MORE_KEYWORDS]...
|| Example: find alice bob charlie
|| Parameters: KEYWORD [MORE_KEYWORDS]...
|| Example: find alice bob charlie
|| list: Displays all persons in the address book as a list with index numbers.
|| Example: list
|| Example: list
|| view: Views the non-private details of the person identified by the index number in the last shown person listing.
|| Parameters: INDEX
|| Example: view 1
|| Parameters: INDEX
|| Example: view 1
|| viewall: Views the non-private details of the person identified by the index number in the last shown person listing.
|| Parameters: INDEX
|| Example: viewall 1
|| Parameters: INDEX
|| Example: viewall 1
|| help: Shows program usage instructions.
|| Example: help
|| Example: help
|| exit: Exits the program.
|| Example: exit
|| Example: exit
|| ===================================================
|| Enter command: || [Command entered: delete 1]
|| The person index provided is invalid
Expand All @@ -49,26 +49,26 @@
|| Enter command: || [Command entered: add wrong args wrong args]
|| Invalid command format!
|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix.
|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...
|| Example: add John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney
|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...
|| Example: add John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney
|| ===================================================
|| Enter command: || [Command entered: add Valid Name 12345 e/[email protected] a/valid, address]
|| Invalid command format!
|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix.
|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...
|| Example: add John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney
|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...
|| Example: add John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney
|| ===================================================
|| Enter command: || [Command entered: add Valid Name p/12345 [email protected] a/valid, address]
|| Invalid command format!
|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix.
|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...
|| Example: add John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney
|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...
|| Example: add John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney
|| ===================================================
|| Enter command: || [Command entered: add Valid Name p/12345 e/[email protected] valid, address]
|| Invalid command format!
|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix.
|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...
|| Example: add John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney
|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...
|| Example: add John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney
|| ===================================================
|| Enter command: || [Command entered: add Valid Name p/12345 e/[email protected] a/valid, address t/goodTag noPrefixTag]
|| Tags names should be alphanumeric
Expand Down Expand Up @@ -141,14 +141,14 @@
|| Enter command: || [Command entered: view]
|| Invalid command format!
|| view: Views the non-private details of the person identified by the index number in the last shown person listing.
|| Parameters: INDEX
|| Example: view 1
|| Parameters: INDEX
|| Example: view 1
|| ===================================================
|| Enter command: || [Command entered: viewall]
|| Invalid command format!
|| viewall: Views the non-private details of the person identified by the index number in the last shown person listing.
|| Parameters: INDEX
|| Example: viewall 1
|| Parameters: INDEX
|| Example: viewall 1
|| ===================================================
|| Enter command: || [Command entered: view should be only one number]
|| The person index provided is invalid
Expand Down Expand Up @@ -201,8 +201,8 @@
|| Enter command: || [Command entered: find]
|| Invalid command format!
|| find: Finds all persons whose names contain any of the specified keywords (case-sensitive) and displays them as a list with index numbers.
|| Parameters: KEYWORD [MORE_KEYWORDS]...
|| Example: find alice bob charlie
|| Parameters: KEYWORD [MORE_KEYWORDS]...
|| Example: find alice bob charlie
|| ===================================================
|| Enter command: || [Command entered: find bet]
||
Expand Down Expand Up @@ -236,8 +236,8 @@
|| Enter command: || [Command entered: delete]
|| Invalid command format!
|| delete: Deletes the person identified by the index number used in the last person listing.
|| Parameters: INDEX
|| Example: delete 1
|| Parameters: INDEX
|| Example: delete 1
|| ===================================================
|| Enter command: || [Command entered: delete should be only one number]
|| The person index provided is invalid
Expand Down