Enhanced track command

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

View file

@ -30,19 +30,26 @@ var trackCmd = &cobra.Command{
log.Fatal(err) log.Fatal(err)
} }
_, err = database.AddEntry(user, newEntry, true) isRunning := newEntry.Finish.IsZero()
_, err = database.AddEntry(user, newEntry, isRunning)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
outputPrefix := "began tracking"
if isRunning == false {
outputPrefix = "tracked"
}
if newEntry.Task != "" && newEntry.Project != "" { 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 == "" { } 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 != "" { } 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 { } else {
fmt.Printf("▷ began tracking task\n") fmt.Printf("▷ %s task\n", outputPrefix)
} }
return return
}, },