From 6732d9634a767e1f195b35775db1bf546a071fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9E=E3=83=AA=E3=82=A6=E3=82=B9?= Date: Sat, 17 Oct 2020 21:14:00 +0100 Subject: [PATCH] Added full output to entry.GetOutput --- z/entry.go | 11 +++++++++-- z/listCmd.go | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/z/entry.go b/z/entry.go index 942bb65..9911493 100644 --- a/z/entry.go +++ b/z/entry.go @@ -147,11 +147,18 @@ func (entry *Entry) GetOutputForFinish() (string) { return fmt.Sprintf("%s finished tracking task%s\n", CharFinish, outputSuffix) } -func (entry *Entry) GetOutput() (string) { +func (entry *Entry) GetOutput(full bool) (string) { + var output string = "" trackDiff := entry.Finish.Sub(entry.Begin) trackDiffOut := time.Time{}.Add(trackDiff) - return fmt.Sprintf("%s %s on %s from %s to %s (%sh)", color.FgGray.Render(entry.ID), color.FgLightWhite.Render(entry.Task), color.FgLightWhite.Render(entry.Project), color.FgLightWhite.Render(entry.Begin.Format("2006-01-02 15:04 -0700")), color.FgLightWhite.Render(entry.Finish.Format("2006-01-02 15:04 -0700")), color.FgLightWhite.Render(trackDiffOut.Format("15:04"))) + if full == false { + output = fmt.Sprintf("%s %s on %s from %s to %s (%sh)", color.FgGray.Render(entry.ID), color.FgLightWhite.Render(entry.Task), color.FgLightWhite.Render(entry.Project), color.FgLightWhite.Render(entry.Begin.Format("2006-01-02 15:04 -0700")), color.FgLightWhite.Render(entry.Finish.Format("2006-01-02 15:04 -0700")), color.FgLightWhite.Render(trackDiffOut.Format("15:04"))) + } else { + output = fmt.Sprintf("%s\n %s on %s\n %sh from %s to %s\n\n Notes:\n %s\n", color.FgGray.Render(entry.ID), color.FgLightWhite.Render(entry.Task), color.FgLightWhite.Render(entry.Project), color.FgLightWhite.Render(trackDiffOut.Format("15:04")), color.FgLightWhite.Render(entry.Begin.Format("2006-01-02 15:04 -0700")), color.FgLightWhite.Render(entry.Finish.Format("2006-01-02 15:04 -0700")), color.FgLightWhite.Render(strings.Replace(entry.Notes, "\n", "\n ", -1)) ) + } + + return output } func GetFilteredEntries(entries []Entry, project string, task string, since time.Time, until time.Time) ([]Entry, error) { diff --git a/z/listCmd.go b/z/listCmd.go index fdd852a..f82c856 100644 --- a/z/listCmd.go +++ b/z/listCmd.go @@ -54,7 +54,7 @@ var listCmd = &cobra.Command{ duration := entry.Finish.Sub(entry.Begin) durationDec := decimal.NewFromFloat(duration.Hours()) totalHours = totalHours.Add(durationDec) - fmt.Printf("%s\n", entry.GetOutput()) + fmt.Printf("%s\n", entry.GetOutput(false)) } if listTotalTime == true {