Skip to content

Commit

Permalink
fix: Better debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
kdheepak committed May 12, 2024
1 parent c3f2d06 commit a9dd570
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 107 deletions.
149 changes: 65 additions & 84 deletions docs/taskwarrior-tui.1
Original file line number Diff line number Diff line change
@@ -1,117 +1,99 @@
.\" Automatically generated by Pandoc 3.1.6
.\" Automatically generated by Pandoc 3.1.7
.\"
.\" Define V font for inline verbatim, using C font in formats
.\" that render this, and otherwise B font.
.ie "\f[CB]x\f[]"x" \{\
. ftr V B
. ftr VI BI
. ftr VB B
. ftr VBI BI
.\}
.el \{\
. ftr V CR
. ftr VI CI
. ftr VB CB
. ftr VBI CBI
.\}
.TH "taskwarrior-tui" "1" "" "" ""
.hy
.SH NAME
.PP
taskwarrior-tui \[em] A terminal user interface for taskwarrior
(https://github.com/kdheepak/taskwarrior-tui)
.SH SYNOPSIS
\f[CR]taskwarrior-tui\f[R]
.PP
\f[V]taskwarrior-tui\f[R]
.PP
\f[B]\f[VB]taskwarrior-tui\f[B]\f[R] is a terminal user interface for
\f[V]taskwarrior\f[R].
\f[B]\f[CB]taskwarrior-tui\f[B]\f[R] is a terminal user interface for
\f[CR]taskwarrior\f[R].
.SH EXAMPLES
.TP
\f[V]taskwarrior-tui\f[R]
Starts a terminal user interface for \f[V]taskwarrior\f[R].
\f[CR]taskwarrior-tui\f[R]
Starts a terminal user interface for \f[CR]taskwarrior\f[R].
.TP
\f[V]alias tt=taskwarrior-tui\f[R]
Add the above to your dotfiles to use \f[V]tt\f[R] to start
\f[V]taskwarrior-tui\f[R].
\f[CR]alias tt=taskwarrior-tui\f[R]
Add the above to your dotfiles to use \f[CR]tt\f[R] to start
\f[CR]taskwarrior-tui\f[R].
.SH KEYBINDINGS
.PP
Keybindings:
.TP
\f[V]Esc\f[R]
\f[CR]Esc\f[R]
Exit current action
.TP
\f[V]]\f[R]
\f[CR]]\f[R]
Next view - Go to next view
.TP
\f[V][\f[R]
\f[CR][\f[R]
Previous view - Go to previous view
.PP
Keybindings for task report:
.TP
\f[V]/\f[R]
\f[CR]/\f[R]
task {string} - Filter task report
.TP
\f[V]a\f[R]
\f[CR]a\f[R]
task add {string} - Add new task
.TP
\f[V]d\f[R]
\f[CR]d\f[R]
task {selected} done - Mark task as done
.TP
\f[V]e\f[R]
\f[CR]e\f[R]
task {selected} edit - Open selected task in editor
.TP
\f[V]j\f[R]
\f[CR]j\f[R]
{selected+=1} - Move down in task report
.TP
\f[V]k\f[R]
\f[CR]k\f[R]
{selected-=1} - Move up in task report
.TP
\f[V]J\f[R]
\f[CR]J\f[R]
{selected+=pageheight} - Move page down in task report
.TP
\f[V]K\f[R]
\f[CR]K\f[R]
{selected-=pageheight} - Move page up in task report
.TP
\f[V]g\f[R]
\f[CR]g\f[R]
{selected=first} - Go to top
.TP
\f[V]G\f[R]
\f[CR]G\f[R]
{selected=last} - Go to bottom
.TP
\f[V]l\f[R]
\f[CR]l\f[R]
task log {string} - Log new task
.TP
\f[V]m\f[R]
\f[CR]m\f[R]
task {selected} modify {string} - Modify selected task
.TP
\f[V]q\f[R]
\f[CR]q\f[R]
exit - Quit
.TP
\f[V]s\f[R]
\f[CR]s\f[R]
task {selected} start/stop - Toggle start and stop
.TP
\f[V]t\f[R]
\f[CR]t\f[R]
task {selected} +{tag}/-{tag} - Toggle
{uda.taskwarrior-tui.quick-tag.name} (default: \f[V]next\f[R])
{uda.taskwarrior-tui.quick-tag.name} (default: \f[CR]next\f[R])
.TP
\f[V]u\f[R]
\f[CR]u\f[R]
task undo - Undo
.TP
\f[V]v\f[R]
\f[CR]v\f[R]
{toggle mark on selected} - Toggle mark on selected
.TP
\f[V]V\f[R]
\f[CR]V\f[R]
{toggle marks on all tasks} - Toggle marks on all tasks in current
filter report
.TP
\f[V]x\f[R]
\f[CR]x\f[R]
task delete {selected} - Delete
.TP
\f[V]z\f[R]
\f[CR]z\f[R]
toggle task info - Toggle task info view
.TP
\f[V]A\f[R]
\f[CR]A\f[R]
task {selected} annotate {string} - Annotate current task
.TP
Ctrl-e
Expand All @@ -120,111 +102,110 @@ scroll down task details - Scroll task details view down one line
Ctrl-y
scroll up task details - Scroll task details view up one line
.TP
\f[V]!\f[R]
\f[CR]!\f[R]
{string} - Custom shell command
.TP
\f[V]1-9\f[R]
\f[CR]1-9\f[R]
{string} - Run user defined shortcuts
.TP
\f[V]:\f[R]
\f[CR]:\f[R]
{task id} - Jump to task id
.TP
\f[V]c\f[R]
\f[CR]c\f[R]
context switcher menu - Open context switcher menu
.TP
\f[V]?\f[R]
\f[CR]?\f[R]
help - Help menu
.PP
Keybindings for filter / command prompt:
.TP
\f[V]Ctrl + f | Right\f[R]
\f[CR]Ctrl + f | Right\f[R]
move forward - Move forward one character
.TP
\f[V]Ctrl + b | Left\f[R]
\f[CR]Ctrl + b | Left\f[R]
move backward - Move backward one character
.TP
\f[V]Ctrl + h | Backspace\f[R]
\f[CR]Ctrl + h | Backspace\f[R]
backspace - Delete one character back
.TP
\f[V]Ctrl + d | Delete\f[R]
\f[CR]Ctrl + d | Delete\f[R]
delete - Delete one character forward
.TP
\f[V]Ctrl + a | Home\f[R]
\f[CR]Ctrl + a | Home\f[R]
home - Go to the beginning of line
.TP
\f[V]Ctrl + e | End\f[R]
\f[CR]Ctrl + e | End\f[R]
end - Go to the end of line
.TP
\f[V]Ctrl + k\f[R]
\f[CR]Ctrl + k\f[R]
delete to end - Delete to the end of line
.TP
\f[V]Ctrl + u\f[R]
\f[CR]Ctrl + u\f[R]
delete to beginning - Delete to the beginning of line
.TP
\f[V]Ctrl + w\f[R]
\f[CR]Ctrl + w\f[R]
delete previous word - Delete previous word
.TP
\f[V]Alt + d\f[R]
\f[CR]Alt + d\f[R]
delete next word - Delete next word
.TP
\f[V]Alt + b\f[R]
\f[CR]Alt + b\f[R]
move to previous word - Move to previous word
.TP
\f[V]Alt + f\f[R]
\f[CR]Alt + f\f[R]
move to next word - Move to next word
.TP
\f[V]Alt + t\f[R]
\f[CR]Alt + t\f[R]
transpose words - Transpose words
.TP
\f[V]Up\f[R]
\f[CR]Up\f[R]
scroll history - Go backward in history matching from beginning of line
to cursor
.TP
\f[V]Down\f[R]
\f[CR]Down\f[R]
scroll history - Go forward in history matching from beginning of line
to cursor
.TP
\f[V]TAB | Ctrl + n\f[R]
\f[CR]TAB | Ctrl + n\f[R]
tab complete - Open tab completion and selection first element OR cycle
to next element
.TP
\f[V]BACKTAB | Ctrl + p\f[R]
\f[CR]BACKTAB | Ctrl + p\f[R]
tab complete - Cycle to previous element
.PP
Keybindings for context switcher:
.TP
\f[V]j\f[R]
\f[CR]j\f[R]
{selected+=1} - Move forward a context
.TP
\f[V]k\f[R]
\f[CR]k\f[R]
{selected-=1} - Move back a context
.PP
Keybindings for calendar:
.TP
\f[V]j\f[R]
\f[CR]j\f[R]
{selected+=1} - Move forward a year in calendar
.TP
\f[V]k\f[R]
\f[CR]k\f[R]
{selected-=1} - Move back a year in calendar
.TP
\f[V]J\f[R]
\f[CR]J\f[R]
{selected+=10} - Move forward a decade in calendar
.TP
\f[V]K\f[R]
\f[CR]K\f[R]
{selected-=10} - Move back a decade in calendar
.SH EXIT STATUSES
.TP
0
If everything goes OK.
.SH AUTHOR
.PP
\f[V]taskwarrior-tui\f[R] is maintained by Dheepak `kdheepak'
\f[CR]taskwarrior-tui\f[R] is maintained by Dheepak `kdheepak'
Krishnamurthy and other contributors.
.PP
\f[B]Source code:\f[R]
\f[V]https://github.com/kdheepak/taskwarrior-tui/\f[R]
\f[CR]https://github.com/kdheepak/taskwarrior-tui/\f[R]
.PD 0
.P
.PD
\f[B]Contributors:\f[R]
\f[V]https://github.com/kdheepak/taskwarrior-tui/graphs/contributors\f[R]
\f[CR]https://github.com/kdheepak/taskwarrior-tui/graphs/contributors\f[R]
56 changes: 33 additions & 23 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1662,18 +1662,23 @@ impl TaskwarriorTui {
let error = String::from_utf8_lossy(&output.stderr);

if output.status.success() {
if let Ok(imported) = import(data.as_bytes()) {
self.all_tasks = imported;
info!("Imported {} tasks", self.tasks.len());
self.error = None;
if self.mode == Mode::Tasks(Action::Error) {
self.mode = self.previous_mode.clone().unwrap_or(Mode::Tasks(Action::Report));
self.previous_mode = None;
let imported = import(data.as_bytes());
match imported {
Ok(imported) => {
self.all_tasks = imported;
info!("Imported {} tasks", self.tasks.len());
self.error = None;
if self.mode == Mode::Tasks(Action::Error) {
self.mode = self.previous_mode.clone().unwrap_or(Mode::Tasks(Action::Report));
self.previous_mode = None;
}
}
Err(err) => {
self.error = Some(format!("Unable to parse output of `{:?}`:\n`{:?}`\n\n{}", task, data, err));
self.mode = Mode::Tasks(Action::Error);
debug!("Unable to parse output: {:?}", data);
debug!("Error: {:?}", err);
}
} else {
self.error = Some(format!("Unable to parse output of `{:?}`:\n`{:?}`", task, data));
self.mode = Mode::Tasks(Action::Error);
debug!("Unable to parse output: {:?}", data);
}
} else {
self.error = Some(format!("Cannot run `{:?}` - ({}) error:\n{}", &task, output.status, error));
Expand Down Expand Up @@ -1715,24 +1720,29 @@ impl TaskwarriorTui {
task.arg(&self.report);
}

info!("Running `{:?}`", task);
info!("Running `{:#?}`", task);
let output = task.output()?;
let data = String::from_utf8_lossy(&output.stdout);
let error = String::from_utf8_lossy(&output.stderr);

if output.status.success() {
if let Ok(imported) = import(data.as_bytes()) {
self.tasks = imported;
info!("Imported {} tasks", self.tasks.len());
self.error = None;
if self.mode == Mode::Tasks(Action::Error) {
self.mode = self.previous_mode.clone().unwrap_or(Mode::Tasks(Action::Report));
self.previous_mode = None;
let imported = import(data.as_bytes());
match imported {
Ok(imported) => {
self.tasks = imported;
info!("Imported {} tasks", self.tasks.len());
self.error = None;
if self.mode == Mode::Tasks(Action::Error) {
self.mode = self.previous_mode.clone().unwrap_or(Mode::Tasks(Action::Report));
self.previous_mode = None;
}
}
Err(err) => {
self.error = Some(format!("Unable to parse output of `{:?}`:\n`{:?}`", task, data));
self.mode = Mode::Tasks(Action::Error);
debug!("Unable to parse output:\n\n{}", data);
debug!("Error: {:?}", err);
}
} else {
self.error = Some(format!("Unable to parse output of `{:?}`:\n`{:?}`", task, data));
self.mode = Mode::Tasks(Action::Error);
debug!("Unable to parse output: {:?}", data);
}
} else {
self.error = Some(format!("Cannot run `{:?}` - ({}) error:\n{}", &task, output.status, error));
Expand Down

0 comments on commit a9dd570

Please sign in to comment.