From 3dade7369262dae3b6305831c5360d09c37af105 Mon Sep 17 00:00:00 2001 From: Or Waichman <86429005+orwaichman@users.noreply.github.com> Date: Wed, 15 Jan 2025 18:49:30 +0200 Subject: [PATCH] Added methods to color text in red and green (#1331) --- utils/coreutils/cmdutils.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/utils/coreutils/cmdutils.go b/utils/coreutils/cmdutils.go index d57783c75..791cce9e8 100644 --- a/utils/coreutils/cmdutils.go +++ b/utils/coreutils/cmdutils.go @@ -230,7 +230,7 @@ func extractBoolOptionFromArgs(args []string, optionName string) (cleanArgs []st // Add green color style to the string if possible. func PrintTitle(str string) string { - return colorStr(str, color.Green) + return PrintGreen(str) } // Add cyan color style to the string if possible. @@ -253,11 +253,21 @@ func PrintComment(str string) string { return colorStr(str, color.Gray) } +// Add red color style to the string if possible. +func PrintRed(str string) string { + return colorStr(str, color.Red) +} + // Add yellow color style to the string if possible. func PrintYellow(str string) string { return colorStr(str, color.Yellow) } +// Add green color style to the string if possible. +func PrintGreen(str string) string { + return colorStr(str, color.Green) +} + // Add the requested style to the string if possible. func colorStr(str string, c color.Color) string { // Add styles only on supported terminals