Skip to content

Commit 9aa2ea7

Browse files
Merge pull request #36 from snyk/feat/success-in-green
feat: highlight a successful run as in legacy CLI, with green text and a checkmark
2 parents a117538 + 035cdc5 commit 9aa2ea7

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

internal/presenters/funcs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ func getCliTemplateFuncMap(tmpl *template.Template) template.FuncMap {
284284
fnMap["box"] = func(s string) string { return boxStyle.Render(s) }
285285
fnMap["toUpperCase"] = strings.ToUpper
286286
fnMap["renderInSeverityColor"] = renderSeverityColor
287+
fnMap["renderGreen"] = renderGreen
287288
fnMap["bold"] = renderBold
288289
fnMap["tip"] = func(s string) string {
289290
return RenderTip(s + "\n")

internal/presenters/styles.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ func renderSeverityColor(severity string) string {
3636
severityStyle := lipgloss.NewStyle().Foreground(style)
3737
return severityStyle.Render(severity)
3838
}
39+
40+
// renderGreen renders text in green.
41+
func renderGreen(str string) string {
42+
style := lipgloss.NewStyle().Foreground(lipgloss.Color("2"))
43+
return style.Render(str)
44+
}

internal/presenters/templates/unified_finding.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@
114114
{{- $vulnerablePaths := len .Findings }}
115115

116116
{{- if gt .DependencyCount 0 -}}
117-
{{- printf "\nTested %d dependencies for known issues, found %d issues, %d vulnerable paths.\n" .DependencyCount $totalIssues $vulnerablePaths -}}
117+
{{- if eq $totalIssues 0 -}}
118+
{{- printf "\n✔ Tested %d dependencies for known issues, no vulnerable paths found.\n" .DependencyCount | renderGreen -}}
119+
{{- else -}}
120+
{{- printf "\nTested %d dependencies for known issues, found %d issues, %d vulnerable paths.\n" .DependencyCount $totalIssues $vulnerablePaths -}}
121+
{{- end -}}
118122
{{- end }}
119123

120124
{{- template "details" . }}

0 commit comments

Comments
 (0)