diff --git a/cmd/root.go b/cmd/root.go index 9812b25..ecc6cdd 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -18,7 +18,7 @@ func Execute() { currentUser, err := user.Current() if err != nil { - die("Error getting your home directory, This is a fatal error; let @dhth know about this.\n%s\n", err) + die("Error getting your home directory, This is a fatal error; use -db-path to specify database path manually.\n%s\n", err) } defaultDBPath := fmt.Sprintf("%s/hours.v%s.db", currentUser.HomeDir, DB_VERSION) diff --git a/internal/ui/render_helpers.go b/internal/ui/render_helpers.go index 447525a..2a5bf5e 100644 --- a/internal/ui/render_helpers.go +++ b/internal/ui/render_helpers.go @@ -27,3 +27,10 @@ func (t *task) updateDesc() { t.desc = fmt.Sprintf("%s %s", RightPadTrim(lastUpdated, 60), timeSpent) } + +func (tl *taskLogEntry) updateDesc() { + secsSpent := int(tl.endTS.Sub(tl.beginTS).Seconds()) + timeSpentStr := humanizeDuration(secsSpent) + + tl.desc = fmt.Sprintf("%s (spent %s)", RightPadTrim(humanize.Time(tl.beginTS), 60), timeSpentStr) +} diff --git a/internal/ui/types.go b/internal/ui/types.go index 160eb5b..c5b8e9b 100644 --- a/internal/ui/types.go +++ b/internal/ui/types.go @@ -1,10 +1,7 @@ package ui import ( - "fmt" "time" - - "github.com/dustin/go-humanize" ) type task struct { @@ -13,10 +10,10 @@ type task struct { createdAt time.Time updatedAt time.Time trackingActive bool - title string - desc string secsSpent int active bool + title string + desc string } type taskLogEntry struct { @@ -26,6 +23,8 @@ type taskLogEntry struct { beginTS time.Time endTS time.Time comment string + title string + desc string } func (t task) Title() string { @@ -45,12 +44,7 @@ func (e taskLogEntry) Title() string { } func (e taskLogEntry) Description() string { - secsSpent := int(e.endTS.Sub(e.beginTS).Seconds()) - timeSpentStr := humanizeDuration(secsSpent) - - timeStr := fmt.Sprintf("%s (spent %s)", RightPadTrim(humanize.Time(e.beginTS), 30), timeSpentStr) - - return fmt.Sprintf("%s %s", RightPadTrim("["+e.taskSummary+"]", 60), timeStr) + return e.desc } func (e taskLogEntry) FilterValue() string { diff --git a/internal/ui/update.go b/internal/ui/update.go index d9e67e6..790dcf2 100644 --- a/internal/ui/update.go +++ b/internal/ui/update.go @@ -475,7 +475,8 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } else { var items []list.Item for _, e := range msg.entries { - items = append(items, list.Item(e)) + e.updateDesc() + items = append(items, e) } m.taskLogList.SetItems(items) }