Skip to content

Commit e2b5f2b

Browse files
moving stipANSI func() here for reusability
1 parent e4abc1e commit e2b5f2b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

cmd/styles.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
package cmd
22

3-
import "github.com/charmbracelet/lipgloss"
3+
import (
4+
"github.com/charmbracelet/lipgloss"
5+
"regexp"
6+
)
47

58
// This file holds all lipgloss stylization variables in one spot since they
69
// are used throughout the package and don't need to be redeclared.
710
var (
11+
green = lipgloss.NewStyle().Foreground(lipgloss.Color("#38B000"))
12+
red = lipgloss.NewStyle().Foreground(lipgloss.Color("#D00000"))
13+
gray = lipgloss.Color("#777777")
14+
keyMenu = lipgloss.NewStyle().Foreground(lipgloss.Color("#777777"))
815
errorColor = lipgloss.NewStyle().Foreground(lipgloss.Color("#F2055C"))
916
errorBorder = lipgloss.NewStyle().
1017
BorderStyle(lipgloss.RoundedBorder()).
@@ -45,3 +52,9 @@ func getTypeColor(typeName string) string {
4552

4653
return color
4754
}
55+
56+
// stripANSI function is used in tests to strip ANSI for plain text processing
57+
func stripANSI(input string) string {
58+
ansiRegex := regexp.MustCompile(`\x1b\[[0-9;]*m`)
59+
return ansiRegex.ReplaceAllString(input, "")
60+
}

0 commit comments

Comments
 (0)