From 6b3554eadb4f40e81267dd1a3d39b01bcbc20e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9E=E3=83=AA=E3=82=A6=E3=82=B9?= Date: Thu, 15 Oct 2020 00:42:58 +0100 Subject: [PATCH] Enhanced track command --- z/track.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/z/track.go b/z/track.go index 6874ec9..e3d5278 100644 --- a/z/track.go +++ b/z/track.go @@ -30,19 +30,26 @@ var trackCmd = &cobra.Command{ log.Fatal(err) } - _, err = database.AddEntry(user, newEntry, true) + isRunning := newEntry.Finish.IsZero() + + _, err = database.AddEntry(user, newEntry, isRunning) if err != nil { log.Fatal(err) } + outputPrefix := "began tracking" + if isRunning == false { + outputPrefix = "tracked" + } + if newEntry.Task != "" && newEntry.Project != "" { - fmt.Printf("▷ began tracking %s on %s\n", color.FgLightWhite.Render(newEntry.Task), color.FgLightWhite.Render(newEntry.Project)) + fmt.Printf("▷ %s %s on %s\n", outputPrefix, color.FgLightWhite.Render(newEntry.Task), color.FgLightWhite.Render(newEntry.Project)) } else if newEntry.Task != "" && newEntry.Project == "" { - fmt.Printf("▷ began tracking %s\n", color.FgLightWhite.Render(newEntry.Task)) + fmt.Printf("▷ %s %s\n", outputPrefix, color.FgLightWhite.Render(newEntry.Task)) } else if newEntry.Task == "" && newEntry.Project != "" { - fmt.Printf("▷ began tracking task on %s\n", color.FgLightWhite.Render(newEntry.Project)) + fmt.Printf("▷ %s task on %s\n", outputPrefix, color.FgLightWhite.Render(newEntry.Project)) } else { - fmt.Printf("▷ began tracking task\n") + fmt.Printf("▷ %s task\n", outputPrefix) } return },