From 29d9ae587833da2982be56ec01da4727ac89145c Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 6 Dec 2017 01:02:52 -0200 Subject: [PATCH] style: improved goreleaser output - Added paddings - Added total time taken by the release Closes #441 --- goreleaserlib/goreleaser.go | 7 ++++++- main.go | 7 +++++-- pipeline/defaults/defaults.go | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/goreleaserlib/goreleaser.go b/goreleaserlib/goreleaser.go index ada9a8e2d..28ba3f44f 100644 --- a/goreleaserlib/goreleaser.go +++ b/goreleaserlib/goreleaser.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/apex/log" + "github.com/apex/log/handlers/cli" "github.com/goreleaser/goreleaser/config" "github.com/goreleaser/goreleaser/context" "github.com/goreleaser/goreleaser/pipeline" @@ -88,13 +89,17 @@ func Release(flags Flags) error { ctx.Publish = false } ctx.RmDist = flags.Bool("rm-dist") + logger, _ := log.Log.(*log.Logger) + handler, _ := logger.Handler.(*cli.Handler) for _, pipe := range pipes { + handler.Padding = 3 log.Infof("\033[1m%s\033[0m", strings.ToUpper(pipe.String())) + handler.Padding = 6 if err := handle(pipe.Run(ctx)); err != nil { return err } } - log.Infof("\033[1mSUCCESS!\033[0m") + handler.Padding = 3 return nil } diff --git a/main.go b/main.go index bd9a023a3..b9b961d7d 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "fmt" "os" + "time" "github.com/apex/log" lcli "github.com/apex/log/handlers/cli" @@ -64,11 +65,13 @@ func main() { }, } app.Action = func(c *cli.Context) error { - log.Infof("running goreleaser %v", version) + start := time.Now() + log.Infof("\033[1mreleasing...\033[0m") if err := goreleaserlib.Release(c); err != nil { - log.WithError(err).Error("release failed") + log.WithError(err).Errorf("\033[1mrelease failed after %0.2fs\033[0m", time.Since(start).Seconds()) return cli.NewExitError("\n", 1) } + log.Infof("\033[1mrelease succeeded after %0.2fs\033[0m", time.Since(start).Seconds()) return nil } app.Commands = []cli.Command{ diff --git a/pipeline/defaults/defaults.go b/pipeline/defaults/defaults.go index c1e69cd76..779891340 100644 --- a/pipeline/defaults/defaults.go +++ b/pipeline/defaults/defaults.go @@ -40,7 +40,7 @@ func (Pipe) Run(ctx *context.Context) error { ctx.Config.Dist = "dist" } for _, defaulter := range defaulters { - log.Infof("\t%s", defaulter.String()) + log.Info(defaulter.String()) if err := defaulter.Default(ctx); err != nil { return err }