mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-25 08:47:18 +02:00
Add error message support to task done
This commit is contained in:
parent
ed3180ef2d
commit
b706f34b53
2 changed files with 14 additions and 10 deletions
16
src/app.rs
16
src/app.rs
|
@ -656,22 +656,20 @@ impl App {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn task_done(&mut self) {
|
||||
pub fn task_done(&mut self) -> Result<(), String> {
|
||||
if self.tasks.len() == 0 {
|
||||
return
|
||||
return Ok(());
|
||||
}
|
||||
let selected = self.state.selected().unwrap_or_default();
|
||||
let task_id = self.tasks[selected].id().unwrap_or_default();
|
||||
let output = Command::new("task")
|
||||
.arg("done")
|
||||
.arg(format!("{}", task_id))
|
||||
.output()
|
||||
.expect(
|
||||
&format!(
|
||||
"Cannot run `task done` for task `{}`. Check documentation for more information",
|
||||
task_id
|
||||
)[..],
|
||||
);
|
||||
.output();
|
||||
match output {
|
||||
Ok(_) => Ok(()),
|
||||
Err(_) => Err(format!("Cannot run `task done` for task `{}`. Check documentation for more information", task_id))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn task_undo(&self) -> Result<(), String> {
|
||||
|
|
|
@ -54,7 +54,13 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
Key::Char('r') => app.update(),
|
||||
Key::Down | Key::Char('j') => app.next(),
|
||||
Key::Up | Key::Char('k') => app.previous(),
|
||||
Key::Char('d') => app.task_done(),
|
||||
Key::Char('d') => match app.task_done() {
|
||||
Ok(_) => (),
|
||||
Err(e) => {
|
||||
app.mode = AppMode::TaskError;
|
||||
app.error = e;
|
||||
}
|
||||
},
|
||||
Key::Char('x') => match app.task_delete() {
|
||||
Ok(_) => (),
|
||||
Err(e) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue