Skip to content

Commit

Permalink
Add clear confirmation (#20)
Browse files Browse the repository at this point in the history
* add confirmation before clearing the tasks

* Update readme.md

---------

Co-authored-by: Abhishek Prakash <abhishek.prakash@flexiloans.com>
  • Loading branch information
abhishek6262 and abhishek-prakash-flexiloans committed Jul 31, 2024
1 parent cd1aaae commit 9f8ba85
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Timo is a command-line application that allows you to capture and manage your th

Here's a glimpse into what's coming next for Timo:

1. **Labels (Implemented)**: Add labels to your thoughts to categorize them and make them easier to search and list.
2. **Reminders (Planned)**: Set reminders for your thoughts and get notified at the specified time.
3. **Clear Confirmation (Planned)**: Implement a confirmation step before clearing all thoughts to prevent accidental data loss.
1. **Labels (Done)**: Add labels to your thoughts to categorize them and make them easier to search and list.
2. **Clear Confirmation (Done)**: Implement a confirmation step before clearing all thoughts to prevent accidental data loss.
3. **Reminders (Planned)**: Set reminders for your thoughts and get notified at the specified time.

**Note**: The roadmap is subject to change based on priorities and development progress.

Expand Down Expand Up @@ -68,7 +68,7 @@ timo add Work on report
### Clear All Thoughts

```bash
timo clear
timo clear --confirmed
```

This command will remove all thoughts from the list.
Expand Down
5 changes: 4 additions & 1 deletion src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ pub enum Commands {
},

#[command(about = "Remove all thoughts from the list")]
Clear,
Clear {
#[arg(required = true, long)]
confirmed: bool,
},

#[command(about = "Remove a thought from the list")]
Remove {
Expand Down
2 changes: 1 addition & 1 deletion src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl Executor {
Commands::Add { text, label } => task_service.add_task(text, label),
Commands::Search { key, label } => task_service.search_task(key, label),
Commands::List { label } => task_service.list_tasks(label),
Commands::Clear => task_service.clear_tasks(),
Commands::Clear { confirmed } => task_service.clear_tasks(confirmed),
Commands::Remove { ids } => task_service.remove_task(ids),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/task_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl<'a> TaskService<'a> {
self.task_repository.add(&content, &label);
}

pub fn clear_tasks(&self) {
pub fn clear_tasks(&self, _: &bool) {
self.task_repository.delete_all();
}

Expand Down

0 comments on commit 9f8ba85

Please sign in to comment.