Add error message support to task undo

This commit is contained in:
Dheepak Krishnamurthy 2020-07-30 15:54:48 -06:00
parent d13ae4b567
commit ed3180ef2d
2 changed files with 15 additions and 5 deletions

View file

@ -674,15 +674,19 @@ impl App {
);
}
pub fn task_undo(&self) {
pub fn task_undo(&self) -> Result<(), String> {
if self.tasks.len() == 0 {
return
return Ok(());
}
let output = Command::new("task")
.arg("rc.confirmation=off")
.arg("undo")
.output()
.expect("Cannot run `task undo`. Check documentation for more information");
.output();
match output {
Ok(_) => Ok(()),
Err(_) => Err("Cannot run `task undo`. Check documentation for more information".to_string()),
}
}
pub fn task_edit(&self) {

View file

@ -69,7 +69,13 @@ fn main() -> Result<(), Box<dyn Error>> {
app.error = e;
}
},
Key::Char('u') => app.task_undo(),
Key::Char('u') => match app.task_undo() {
Ok(_) => (),
Err(e) => {
app.mode = AppMode::TaskError;
app.error = e;
}
},
Key::Char('e') => {
events.pause_event_loop(&mut terminal);
app.task_edit();