mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-26 12:17:19 +02:00
Add edit feature
This commit is contained in:
parent
9557688714
commit
2a08fb2f33
1 changed files with 31 additions and 0 deletions
31
src/app.rs
31
src/app.rs
|
@ -409,6 +409,36 @@ impl App {
|
||||||
.expect("Cannot run `task undo`. Check documentation for more information");
|
.expect("Cannot run `task undo`. Check documentation for more information");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn task_edit(&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 r = Command::new("task")
|
||||||
|
.arg("edit")
|
||||||
|
.arg(format!("{}", task_id))
|
||||||
|
.spawn();
|
||||||
|
|
||||||
|
// TODO: fix vim hanging
|
||||||
|
match r {
|
||||||
|
Ok(mut child) => {
|
||||||
|
child
|
||||||
|
.wait()
|
||||||
|
.expect(
|
||||||
|
&format!(
|
||||||
|
"Cannot run `task edit` for task `{}`. Check documentation for more information",
|
||||||
|
task_id
|
||||||
|
)[..],
|
||||||
|
);
|
||||||
|
println!("Opening task ...");
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
println!("Vim failed to start");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn handle_input(&mut self, event: Key) {
|
pub fn handle_input(&mut self, event: Key) {
|
||||||
match self.mode {
|
match self.mode {
|
||||||
AppMode::Report => match event {
|
AppMode::Report => match event {
|
||||||
|
@ -418,6 +448,7 @@ impl App {
|
||||||
Key::Up | Key::Char('k') => self.previous(),
|
Key::Up | Key::Char('k') => self.previous(),
|
||||||
Key::Char('d') => self.task_done(),
|
Key::Char('d') => self.task_done(),
|
||||||
Key::Char('u') => self.task_undo(),
|
Key::Char('u') => self.task_undo(),
|
||||||
|
Key::Char('e') => self.task_edit(),
|
||||||
Key::Char('/') => {
|
Key::Char('/') => {
|
||||||
self.mode = AppMode::Filter;
|
self.mode = AppMode::Filter;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue