Skip to content

Commit

Permalink
Colorize make targets
Browse files Browse the repository at this point in the history
  • Loading branch information
zph committed Sep 23, 2019
1 parent 0ab6aef commit 7f8d900
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
7 changes: 4 additions & 3 deletions help/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"sort"
"strings"

"github.com/fatih/color"
"github.com/pkg/errors"

"github.com/tj/mmake/parser"
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
}

0 comments on commit 7f8d900

Please sign in to comment.