Enhanced output of finish command

This commit is contained in:
マリウス 2020-10-15 00:49:53 +01:00
parent 6b3554eadb
commit 21584d2680
No known key found for this signature in database
GPG key ID: C228EF0A530AF06F

View file

@ -59,12 +59,15 @@ var finishCmd = &cobra.Command{
log.Fatal(err) log.Fatal(err)
} }
trackDiff := runningEntry.Finish.Sub(runningEntry.Begin)
trackDiffOut := time.Time{}.Add(trackDiff)
if runningEntry.Task != "" && runningEntry.Project != "" { if runningEntry.Task != "" && runningEntry.Project != "" {
fmt.Printf("□ finished tracking %s on %s\n", color.FgLightWhite.Render(runningEntry.Task), color.FgLightWhite.Render(runningEntry.Project)) fmt.Printf("□ finished tracking %s on %s for %sh\n", color.FgLightWhite.Render(runningEntry.Task), color.FgLightWhite.Render(runningEntry.Project), trackDiffOut.Format("15:04"))
} else if runningEntry.Task != "" && runningEntry.Project == "" { } else if runningEntry.Task != "" && runningEntry.Project == "" {
fmt.Printf("□ finished tracking %s\n", color.FgLightWhite.Render(runningEntry.Task)) fmt.Printf("□ finished tracking %s for %sh\n", color.FgLightWhite.Render(runningEntry.Task), trackDiffOut.Format("15:04"))
} else if runningEntry.Task == "" && runningEntry.Project != "" { } else if runningEntry.Task == "" && runningEntry.Project != "" {
fmt.Printf("□ finished tracking task on %s\n", color.FgLightWhite.Render(runningEntry.Project)) fmt.Printf("□ finished tracking task on %s for %sh\n", color.FgLightWhite.Render(runningEntry.Project), trackDiffOut.Format("15:04"))
} else { } else {
fmt.Printf("□ finished tracking task\n") fmt.Printf("□ finished tracking task\n")
} }