Added full output to entry.GetOutput
This commit is contained in:
parent
2ecc0a70ca
commit
6732d9634a
2 changed files with 10 additions and 3 deletions
11
z/entry.go
11
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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue