From 7f8d9001f224fffee52beec195730651f290b676 Mon Sep 17 00:00:00 2001 From: Zander Hill Date: Mon, 23 Sep 2019 16:47:20 +0100 Subject: [PATCH 1/2] Colorize make targets --- go.mod | 1 + help/help.go | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b2962e7..bd1dac7 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.13 require ( github.com/apex/log v1.1.1 github.com/campoy/tools v1.0.0 // indirect + github.com/fatih/color v1.7.0 github.com/pkg/errors v0.8.1 github.com/segmentio/go-env v1.1.0 ) diff --git a/help/help.go b/help/help.go index b4bc20b..8d470aa 100644 --- a/help/help.go +++ b/help/help.go @@ -8,6 +8,7 @@ import ( "sort" "strings" + "github.com/fatih/color" "github.com/pkg/errors" "github.com/tj/mmake/parser" @@ -59,7 +60,7 @@ func OutputAllLong(r io.Reader, w io.Writer, targets []string) error { // getComments parses, filters, and sorts all comment nodes. func getComments(r io.Reader, targets []string) ([]parser.Comment, error) { nodes, err := parser.ParseRecursive(r, resolver.IncludePath) - + if err != nil { return nil, errors.Wrap(err, "parsing") } @@ -126,7 +127,7 @@ func printVerbose(w io.Writer, c parser.Comment) (int, error) { c.Value = c.Value + " (default)" } - return fmt.Fprintf(w, " %-s:\n%-s\n\n", c.Target, indent(indent(c.Value))) + return fmt.Fprintf(w, " %-s:\n%-s\n\n", color.HiBlueString(c.Target), indent(indent(c.Value))) } func printShort(w io.Writer, c parser.Comment, width int) (int, error) { @@ -135,5 +136,5 @@ func printShort(w io.Writer, c parser.Comment, width int) (int, error) { comment = comment + " (default)" } - return fmt.Fprintf(w, " %-*s %-s\n", width+2, c.Target, comment) + return fmt.Fprintf(w, " %-*s %-s\n", width+2, color.HiBlueString(c.Target), comment) } From bd13ef4badc0240373d7b3dee85dff537c9f6be0 Mon Sep 17 00:00:00 2001 From: Zander Hill Date: Mon, 23 Sep 2019 16:49:12 +0100 Subject: [PATCH 2/2] Fix indentation for help target --- help/help.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/help/help.go b/help/help.go index 8d470aa..536eaee 100644 --- a/help/help.go +++ b/help/help.go @@ -23,7 +23,7 @@ func OutputAllShort(r io.Reader, w io.Writer, targets []string) error { return err } - width := targetWidth(comments) + width := targetWidth(comments) + 15 fmt.Fprintf(w, "\n") for _, c := range comments { if c.Target == "" { @@ -136,5 +136,5 @@ func printShort(w io.Writer, c parser.Comment, width int) (int, error) { comment = comment + " (default)" } - return fmt.Fprintf(w, " %-*s %-s\n", width+2, color.HiBlueString(c.Target), comment) + return fmt.Fprintf(w, " %-*s %-s\n", width+2, color.HiBlueString(c.Target), indent(indent(comment))) }