From 9f8ba851820a671571e21d9b40c418fcbd0537e1 Mon Sep 17 00:00:00 2001 From: Abhishek Prakash Date: Wed, 31 Jul 2024 16:50:14 +0530 Subject: [PATCH] Add clear confirmation (#20) * add confirmation before clearing the tasks * Update readme.md --------- Co-authored-by: Abhishek Prakash --- readme.md | 8 ++++---- src/commands.rs | 5 ++++- src/executor.rs | 2 +- src/task_service.rs | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/readme.md b/readme.md index aff455a..f5cab48 100644 --- a/readme.md +++ b/readme.md @@ -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. @@ -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. diff --git a/src/commands.rs b/src/commands.rs index be7eaa6..a63e7e9 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -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 { diff --git a/src/executor.rs b/src/executor.rs index 2dd291e..ec7100c 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -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), } } diff --git a/src/task_service.rs b/src/task_service.rs index 2c5d7de..d55d22f 100644 --- a/src/task_service.rs +++ b/src/task_service.rs @@ -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(); }