~ghost08/wt

b3cf6018a0c4059723afc2ba7321cd7878959b3a — ghost08 3 years ago f586119
Add colors to status output
3 files changed, 31 insertions(+), 8 deletions(-)

M go.mod
M go.sum
M main.go
M go.mod => go.mod +1 -0
@@ 5,6 5,7 @@ go 1.16
require (
	github.com/360EntSecGroup-Skylar/excelize v1.4.1
	github.com/alecthomas/kong v0.2.16
	github.com/gookit/color v1.4.2
	github.com/hashicorp/errwrap v1.1.0 // indirect
	github.com/hashicorp/go-multierror v1.1.1 // indirect
	github.com/pkg/errors v0.9.1 // indirect

M go.sum => go.sum +6 -0
@@ 5,6 5,8 @@ github.com/alecthomas/kong v0.2.16/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QL
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gookit/color v1.4.2 h1:tXy44JFSFkKnELV6WaMo/lLfu/meqITX3iAV52do7lk=
github.com/gookit/color v1.4.2/go.mod h1:fqRyamkC1W8uxl+lxCQxOT09l/vYfZ+QeiX3rKQHCoQ=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=


@@ 31,6 33,10 @@ github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb/go.mod h1:a8OnR
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44 h1:Bli41pIlzTzf3KEY06n+xnzK/BESIg2ze4Pgfh/aI8c=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=

M main.go => main.go +24 -8
@@ 9,6 9,7 @@ import (
	"time"

	"github.com/alecthomas/kong"
	"github.com/gookit/color"
	"github.com/posener/complete/v2"
	"github.com/posener/complete/v2/install"
	"github.com/posener/complete/v2/predict"


@@ 192,15 193,17 @@ func status() error {
		return fmt.Errorf("loading entries: %w", err)
	}
	if len(es) == 0 || es[0].End != zeroTime {
		fmt.Println("no running entries")
		fmt.Println("\n    no running entries")
	} else {
		last := &es[0]
		fmt.Printf(
			"%s\t%s\nstart: %s\tduration: %s\n",
			last.Project,
			last.Description,
			"\n    %s\t\t%s\n    %s: %s\t%s: %s\n",
			color.FgCyan.Render(last.Project),
			color.FgLightWhite.Render(last.Description),
			color.Style{color.FgLightWhite, color.OpBold}.Render("start"),
			last.Start.Format("15:04:05"),
			time.Now().Sub(last.Start),
			color.Style{color.FgLightWhite, color.OpBold}.Render("duration"),
			color.FgMagenta.Sprint(time.Now().Sub(last.Start)),
		)
	}
	y, m, d := time.Now().Date()


@@ 215,7 218,11 @@ func status() error {
		}
		todayWorked += end.Sub(e.Start)
	}
	fmt.Printf("today worked:\t%s\n", todayWorked)
	fmt.Printf(
		"\n    %s:\t%s\n",
		color.Style{color.FgLightWhite, color.OpBold}.Render("today worked"),
		color.FgMagenta.Sprint(todayWorked),
	)
	for _, e := range es {
		if ey, em, ed := e.Date.Date(); ey != y || em != m || ed != d {
			break


@@ 224,7 231,12 @@ func status() error {
		if end == zeroTime {
			end = time.Now()
		}
		fmt.Printf("%s\t%s\t%s\n", e.Project, e.Description, end.Sub(e.Start))
		fmt.Printf(
			"    %s\t\t%s %s\n",
			color.FgCyan.Render(e.Project),
			color.FgLightWhite.Render(e.Description),
			color.FgMagenta.Sprint(end.Sub(e.Start)),
		)
	}
	var thisMonthWorked time.Duration
	for _, e := range es {


@@ 237,6 249,10 @@ func status() error {
		}
		thisMonthWorked += end.Sub(e.Start)
	}
	fmt.Printf("this month:\t%s\n", thisMonthWorked)
	fmt.Printf(
		"    %s:\t\t%s\n\n",
		color.Style{color.FgLightWhite, color.OpBold}.Render("this month"),
		color.FgMagenta.Render(thisMonthWorked),
	)
	return nil
}