From acd512ab7dac752f27c9b974af5bc0a734681e1b Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Tue, 28 Jul 2020 13:58:03 -0600 Subject: [PATCH] Add delete functionality --- src/app.rs | 20 ++++++++++++++++++++ src/main.rs | 1 + 2 files changed, 21 insertions(+) diff --git a/src/app.rs b/src/app.rs index 4b1fadd..485bcab 100644 --- a/src/app.rs +++ b/src/app.rs @@ -482,6 +482,26 @@ impl App { ); } + pub fn task_delete(&self) { + if self.tasks.len() == 0 { + return + } + let selected = self.state.selected().unwrap_or_default(); + let task_id = self.tasks[selected].id().unwrap_or_default(); + + let output = Command::new("task") + .arg("rc.confirmation=off") + .arg("delete") + .arg(format!("{}", task_id)) + .output() + .expect( + &format!( + "Cannot run `task delete` for task `{}`. Check documentation for more information", + task_id + )[..], + ); + } + pub fn task_done(&mut self) { if self.tasks.len() == 0 { return diff --git a/src/main.rs b/src/main.rs index ccfb329..2ab1fe5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,6 +55,7 @@ fn main() -> Result<(), Box> { Key::Down | Key::Char('j') => app.next(), Key::Up | Key::Char('k') => app.previous(), Key::Char('d') => app.task_done(), + Key::Char('x') => app.task_delete(), Key::Char('s') => app.task_start_or_stop(), Key::Char('u') => app.task_undo(), Key::Char('e') => {