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

Update parser #87

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,7 @@ shadowJar {
}

defaultTasks 'clean', 'test'

run {
enableAssertions = true
}
28 changes: 27 additions & 1 deletion docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ VolunTier is a **desktop app for managing contacts, optimized for use via a Lin

## Quick start

### Installation of application

1. Ensure you have Java `17` or above installed in your Computer.

1. Download the latest `.jar` file from [here](https://github.com/se-edu/addressbook-level3/releases).
Expand All @@ -40,9 +42,33 @@ VolunTier is a **desktop app for managing contacts, optimized for use via a Lin

1. Refer to the [Features](#features) below for details of each command.

### CLI tutorial

This tutorial introduces you to the basics of using the Command Line Interface (CLI) on Unix-based systems (Linux/macOS) and Windows. By the end, you’ll be comfortable navigating the file system, managing files, and running basic commands through the terminal.

#### 1. **What is the CLI?**
The CLI is a text-based interface where users interact with the operating system by typing commands. It allows for:
- **Efficient operations** compared to GUI
- **Advanced automation** with scripts and batch commands

#### 2. **Opening the Terminal**

#### On macOS:
```shell
Cmd + Space

Choose a reason for hiding this comment

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

Hey Mingyang, I don't think command + space is the default shortcut for opening the terminal. Maybe you might want to look into this further?

```

#### On Windows:
Search for command prompt or powershell in the start menu.

#### On Linux:
```shell
Ctrl + Alt + T
```

--------------------------------------------------------------------------------------------------------------------

## Features
#### Features

<box type="info" seamless>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,27 @@ public AddTuteeCommand parse(String args) throws ParseException {
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE,
PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_HOURS, PREFIX_TAG, PREFIX_SUBJECT);

if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_HOURS)
if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS)
|| !argMultimap.getPreamble().isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddTuteeCommand.MESSAGE_USAGE));
}

// Hours is optional for adding a tutee and will be set to 0 if unspecified
Hours hours;
if (!arePrefixesPresent(argMultimap, PREFIX_HOURS)) {
hours = new Hours("0");
} else {
hours = ParserUtil.parseHours(argMultimap.getValue(PREFIX_HOURS).get());
}

argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_HOURS);
Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get());
Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get());
Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get());
Hours hours = ParserUtil.parseHours(argMultimap.getValue(PREFIX_HOURS).get());
Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get());
Set<Tag> tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));
Set<Subject> subjects = ParserUtil.parseSubjects(argMultimap.getAllValues(PREFIX_SUBJECT));

Choose a reason for hiding this comment

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

Nice! Removed dead code. Well done!

//Person person = new Person(name, phone, email, address, hours, tagList, subjects);
Tutee tutee = new Tutee(name, phone, email, address, hours, tagList, subjects);

return new AddTuteeCommand(tutee);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,23 @@ public AddTutorCommand parse(String args) throws ParseException {
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE,
PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_HOURS, PREFIX_TAG, PREFIX_SUBJECT);

if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_HOURS)
if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS)
|| !argMultimap.getPreamble().isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddTutorCommand.MESSAGE_USAGE));
}

// Hours is optional for adding a tutee and will be set to 0 if unspecified

Choose a reason for hiding this comment

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

Good comments letting the reader know what the code does. Very readable, very demure!

Hours hours;
if (!arePrefixesPresent(argMultimap, PREFIX_HOURS)) {
hours = new Hours("0");
} else {
hours = ParserUtil.parseHours(argMultimap.getValue(PREFIX_HOURS).get());
}

argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_HOURS);
Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get());
Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get());
Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get());
Hours hours = ParserUtil.parseHours(argMultimap.getValue(PREFIX_HOURS).get());
Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get());
Set<Tag> tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));
Set<Subject> subjects = ParserUtil.parseSubjects(argMultimap.getAllValues(PREFIX_SUBJECT));
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/seedu/address/logic/parser/CliSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
public class CliSyntax {

/* Prefix definitions */
public static final Prefix PREFIX_NAME = new Prefix("-name ");
public static final Prefix PREFIX_PHONE = new Prefix("-handphone ");
public static final Prefix PREFIX_HOURS = new Prefix("-hours ");
public static final Prefix PREFIX_EMAIL = new Prefix("-email ");
public static final Prefix PREFIX_ADDRESS = new Prefix("-address ");
public static final Prefix PREFIX_TAG = new Prefix("t/"); // TODO change?
public static final Prefix PREFIX_SUBJECT = new Prefix("-subject ");
public static final Prefix PREFIX_FILEPATH = new Prefix("-filepath ");
public static final Prefix PREFIX_NAME = new Prefix("\\n ");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remember to enable the disabled tests!

public static final Prefix PREFIX_PHONE = new Prefix("\\p ");
public static final Prefix PREFIX_HOURS = new Prefix("\\h ");
public static final Prefix PREFIX_EMAIL = new Prefix("\\e ");
public static final Prefix PREFIX_ADDRESS = new Prefix("\\a ");
public static final Prefix PREFIX_TAG = new Prefix("\\t");
public static final Prefix PREFIX_SUBJECT = new Prefix("\\s ");
public static final Prefix PREFIX_FILEPATH = new Prefix("\\f ");


}
Loading