Skip to content

Commit

Permalink
Fix todo bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yisiox committed Feb 16, 2024
1 parent 42bfcae commit 01a1836
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 20 deletions.
73 changes: 57 additions & 16 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,71 @@
# Duke User Guide
# Earl User Guide

// Update the title above to match the actual product name
Earl is a **desktop chat application to track tasks, optimised for
use via a Command Line Interface (CLI)** while still having the
benefits of a Graphical User Interface (GUI). If you can type fast,
Earl can get your task management done faster than traditional GUI
applications.

// Product screenshot goes here
![](Ui.png)

// Product intro goes here
## Features

## Adding deadlines
### Adding ToDos
Adds a todo to the list of tasks.

// Describe the action and its outcome.
Format: `todo <task name>`

// Give examples of usage
Example: `todo homework`, `todo wash clothes`

Example: `keyword (optional arguments)`
*Notes*
+ `<task name>` cannot be empty

// A description of the expected outcome goes here
### Adding Deadlines

```
expected output
```
Adds a deadline to the list of tasks.

## Feature ABC
Format: `deadline <task name> /by <date time>`

// Feature details
Example: `deadline project submission /by 01/01/2024 2359`

*Notes*
+ `<task name>` cannot be empty.
+ `<date time>` must be of the format `dd/mm/yyyy hhmm`

## Feature XYZ
### Adding Events

// Feature details
Adds an event to the list of tasks.

Format: `event <task name> /from <date time> /to <date time>`

Example: `event exam /from 01/01/2024 1200 /to 01/01/2024 1400`

*Notes*
+ `<task name>` cannot be empty.
+ `<date time>` must be of the format `dd/mm/yyyy hhmm`

### List

Displays all tasks currently tracked.

Format: `list`

### Find

Displays all tasks with details matching a pattern.

Format: `find <pattern>`

Example: `find wash clothes`

### Mark

Marks a task as complete.

Format: `mark <index or range> [<index or range>, ...] `

Example: `mark 1 3-5`

*Notes*
+ Arguments are space separated single indices or ranges
+ Ranges must be of the form `<index>-<index>`
Binary file added docs/Ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions src/main/java/earl/logic/DeadlineHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public void handle(TaskList tasks, Ui ui) throws EarlException {
ui.completeResponse();
} catch (IndexOutOfBoundsException e) {
throw new EarlException(
ui.appendNewline("An error befalls.")
+ ui.appendNewline("Example use:")
ui.appendNewline("An error befalls. Example use:")
+ ui.leftPad("deadline <name> /by <due>"));
} catch (Exception e) {
throw new EarlException("Command hath faltered: "
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/earl/logic/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public void handle(TaskList tasks, Ui ui) throws EarlException {
ui.completeResponse();
} catch (IndexOutOfBoundsException e) {
throw new EarlException(
ui.appendNewline("An error befalls.")
+ ui.appendNewline("Example use:")
ui.appendNewline("An error befalls. Example use:")
+ ui.leftPad("event <name>"
+ " /from <start> /to <end>"));
} catch (Exception e) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/earl/logic/TodoHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public TodoHandler(String args) {
@Override
public void handle(TaskList tasks, Ui ui) throws EarlException {
try {
if (args.isEmpty()) {
throw new EarlException("The description is devoid of detail.");
}
Task added = tasks.add(TaskType.TODO.createTask(args));
ui.buildResponse("A new todo, by virtue of your decree,");
ui.buildResponse(
Expand All @@ -27,6 +30,8 @@ public void handle(TaskList tasks, Ui ui) throws EarlException {
ui.buildResponse("The ledger of tasks bears witness to "
+ tasks.getSize() + " endeavours.");
ui.completeResponse();
} catch (EarlException e) {
throw e;
} catch (IndexOutOfBoundsException e) {
throw new EarlException(
ui.appendNewline("An error befalls. Example use:")
Expand Down

0 comments on commit 01a1836

Please sign in to comment.