From 5e3f4eb87f9cda5eb135582274754b8301c88fa6 Mon Sep 17 00:00:00 2001 From: Christopher Phillips Date: Mon, 11 Dec 2023 21:31:04 -0500 Subject: [PATCH] chore: add more color to check output Signed-off-by: Christopher Phillips --- cmd/grant/cli/internal/check/report.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/grant/cli/internal/check/report.go b/cmd/grant/cli/internal/check/report.go index f186db5..2e15138 100644 --- a/cmd/grant/cli/internal/check/report.go +++ b/cmd/grant/cli/internal/check/report.go @@ -2,10 +2,10 @@ package check import ( "errors" - "fmt" "io" "time" + "github.com/gookit/color" list "github.com/jedib0t/go-pretty/v6/list" "github.com/anchore/grant/grant" @@ -72,13 +72,13 @@ func (r *Report) renderTable(out io.Writer) error { for _, res := range r.Results { resulList := newList() uiLists = append(uiLists, resulList) - resulList.AppendItem(res.Case.UserInput) + resulList.AppendItem(color.Primary.Sprintf("%s", res.Case.UserInput)) for _, rule := range res.Case.Policy.Rules { failedEvaluations := r.Results.GetFailedEvaluations(res.Case.UserInput, rule) if len(failedEvaluations) == 0 { resulList.Indent() - resulList.AppendItem("No License Violations Found: ✅") + resulList.AppendItem(color.Success.Sprintf("%s", "No License Violations Found")) resulList.UnIndent() continue } @@ -97,7 +97,7 @@ func (r *Report) renderTable(out io.Writer) error { func renderEvaluations(rule grant.Rule, showPackages bool, l list.Writer, e evalutation.LicenseEvaluations) { l.Indent() - l.AppendItem(fmt.Sprintf("matches for rule: %s; matched with pattern %s", rule.Name, rule.OriginalPattern)) + l.AppendItem(color.Secondary.Sprintf("license matches for rule: %s; matched with pattern %s", rule.Name, rule.OriginalPattern)) licenseTracker := make(map[string]struct{}) for _, eval := range e { @@ -110,7 +110,7 @@ func renderEvaluations(rule grant.Rule, showPackages bool, l list.Writer, e eval if _, ok := licenseTracker[license]; !ok { licenseTracker[license] = struct{}{} l.Indent() - l.AppendItem(fmt.Sprintf("%s", license)) + l.AppendItem(color.Danger.Sprintf("%s", license)) l.UnIndent() } }