From 674d9a4a5d0528bbc0c184de2d271004c0e1c831 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 5 Dec 2021 17:49:53 +0300 Subject: first release --- cmd/ls.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'cmd/ls.go') diff --git a/cmd/ls.go b/cmd/ls.go index 3fe7244..eaf58e1 100644 --- a/cmd/ls.go +++ b/cmd/ls.go @@ -2,8 +2,11 @@ package cmd import ( "strings" + "time" "github.com/spf13/cobra" + + "github.com/neonxp/track/internal/tracker" ) // lsCmd represents the ls command @@ -45,14 +48,26 @@ var lsCmd = &cobra.Command{ if !verbose && i < len(activity.Spans)-1 { continue } - stop := "now" + stop := time.Now() + stopText := "now" if span.Stop != nil { - stop = span.Stop.Format("15:04:05 2.1.2006") + stop = *span.Stop + stopText = span.Stop.Format("15:04 2.1.2006") } if strings.Trim(span.Comment, " ") != "" { - cmd.Printf("\t%s — %s: \"%s\"\n", span.Start.Format("15:04:05 2.1.2006"), stop, span.Comment) + cmd.Printf( + "\t%s — %s (%s): \"%s\"\n", + span.Start.Format("15:04 2.1.2006"), + stopText, + tracker.Timespan(stop.Sub(span.Start)).Format(), + span.Comment) } else { - cmd.Printf("\t%s — %s\n", span.Start.Format("15:04:05 2.1.2006"), stop) + cmd.Printf( + "\t%s — %s (%s)\n", + span.Start.Format("15:04 2.1.2006"), + stopText, + tracker.Timespan(stop.Sub(span.Start)).Format(), + ) } } } -- cgit v1.2.3