mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-25 17:57:19 +02:00
Add log functionality
This commit is contained in:
parent
acd512ab7d
commit
2e32659d22
2 changed files with 45 additions and 0 deletions
25
src/app.rs
25
src/app.rs
|
@ -90,6 +90,7 @@ pub enum AppMode {
|
||||||
Report,
|
Report,
|
||||||
Filter,
|
Filter,
|
||||||
AddTask,
|
AddTask,
|
||||||
|
LogTask,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct App {
|
pub struct App {
|
||||||
|
@ -145,6 +146,16 @@ impl App {
|
||||||
);
|
);
|
||||||
self.draw_command(f, rects[2], &self.filter[..], "Filter");
|
self.draw_command(f, rects[2], &self.filter[..], "Filter");
|
||||||
},
|
},
|
||||||
|
AppMode::LogTask => {
|
||||||
|
f.set_cursor(
|
||||||
|
// Put cursor past the end of the input text
|
||||||
|
rects[2].x + self.command.width() as u16 + 1,
|
||||||
|
// Move one line down, from the border to the input line
|
||||||
|
rects[2].y + 1,
|
||||||
|
);
|
||||||
|
f.render_widget(Clear, rects[2]);
|
||||||
|
self.draw_command(f, rects[2], &self.command[..], "Log Task");
|
||||||
|
},
|
||||||
AppMode::AddTask => {
|
AppMode::AddTask => {
|
||||||
f.set_cursor(
|
f.set_cursor(
|
||||||
// Put cursor past the end of the input text
|
// Put cursor past the end of the input text
|
||||||
|
@ -420,6 +431,20 @@ impl App {
|
||||||
self.update();
|
self.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn task_log(&mut self) {
|
||||||
|
if self.tasks.len() == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let output = Command::new("task")
|
||||||
|
.arg("log")
|
||||||
|
.arg(format!("{}", self.command))
|
||||||
|
.output()
|
||||||
|
.expect("Cannot run `task log`. Check documentation for more information");
|
||||||
|
|
||||||
|
self.command = "".to_string();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn task_add(&mut self) {
|
pub fn task_add(&mut self) {
|
||||||
if self.tasks.len() == 0 {
|
if self.tasks.len() == 0 {
|
||||||
return
|
return
|
||||||
|
|
20
src/main.rs
20
src/main.rs
|
@ -63,6 +63,9 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
app.task_edit();
|
app.task_edit();
|
||||||
events.resume_event_loop(&mut terminal);
|
events.resume_event_loop(&mut terminal);
|
||||||
},
|
},
|
||||||
|
Key::Char('l') => {
|
||||||
|
app.mode = AppMode::LogTask;
|
||||||
|
}
|
||||||
Key::Char('a') => {
|
Key::Char('a') => {
|
||||||
app.mode = AppMode::AddTask;
|
app.mode = AppMode::AddTask;
|
||||||
}
|
}
|
||||||
|
@ -71,6 +74,23 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
|
AppMode::LogTask => match input {
|
||||||
|
Key::Char('\n') => {
|
||||||
|
app.task_log();
|
||||||
|
app.mode = AppMode::Report;
|
||||||
|
}
|
||||||
|
Key::Esc => {
|
||||||
|
app.command = "".to_string();
|
||||||
|
app.mode = AppMode::Report;
|
||||||
|
}
|
||||||
|
Key::Char(c) => {
|
||||||
|
app.command.push(c);
|
||||||
|
}
|
||||||
|
Key::Backspace => {
|
||||||
|
app.command.pop();
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
},
|
||||||
AppMode::AddTask => match input {
|
AppMode::AddTask => match input {
|
||||||
Key::Char('\n') => {
|
Key::Char('\n') => {
|
||||||
app.task_add();
|
app.task_add();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue