mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-27 06:37:19 +02:00
Add delete functionality
This commit is contained in:
parent
fb925e6182
commit
acd512ab7d
2 changed files with 21 additions and 0 deletions
20
src/app.rs
20
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
|
||||
|
|
|
@ -55,6 +55,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
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') => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue