chore(progress)!: migrate progress to lipgloss (#676)

* chore(progress)!: migrate progress to lipgloss

This removes the dependency on termenv and replaces it with lipgloss. This
change also removes the WithColorProfile option, as it is no longer needed.
The new API uses `color.Color` types for colors, which are more flexible and
allow for more advanced color manipulation.

* Update progress/progress_test.go

Co-authored-by: Christian Rocha <christian@rocha.is>

* Update progress/progress_test.go

Co-authored-by: Christian Rocha <christian@rocha.is>

* chore: go mod tidy

---------

Co-authored-by: Christian Rocha <christian@rocha.is>
This commit is contained in:
Ayman Bagabas
2024-12-12 10:51:23 -05:00
committed by GitHub
co-authored by Christian Rocha
parent bd415b4eba
commit 2e3a42396e
4 changed files with 22 additions and 51 deletions
+5 -7
View File
@@ -4,15 +4,14 @@ import (
"strings"
"testing"
"github.com/muesli/termenv"
"github.com/charmbracelet/lipgloss/v2"
)
const (
AnsiReset = "\x1b[0m"
AnsiReset = "\x1b[m"
)
func TestGradient(t *testing.T) {
colA := "#FF0000"
colB := "#00FF00"
@@ -21,7 +20,7 @@ func TestGradient(t *testing.T) {
for _, scale := range []bool{false, true} {
opts := []Option{
WithColorProfile(termenv.TrueColor), WithoutPercentage(),
WithoutPercentage(),
}
if scale {
descr = "progress bar with scaled gradient"
@@ -36,10 +35,10 @@ func TestGradient(t *testing.T) {
// build the expected colors by colorizing an empty string and then cutting off the following reset sequence
sb := strings.Builder{}
sb.WriteString(termenv.String("").Foreground(p.color(colA)).String())
sb.WriteString(lipgloss.NewStyle().Foreground(lipgloss.Color(colA)).String())
expFirst := strings.Split(sb.String(), AnsiReset)[0]
sb.Reset()
sb.WriteString(termenv.String("").Foreground(p.color(colB)).String())
sb.WriteString(lipgloss.NewStyle().Foreground(lipgloss.Color(colB)).String())
expLast := strings.Split(sb.String(), AnsiReset)[0]
for _, width := range []int{3, 5, 50} {
@@ -62,5 +61,4 @@ func TestGradient(t *testing.T) {
}
})
}
}