use lipgloss instead of termenv

This commit is contained in:
Daylin Morgan 2024-06-03 18:39:29 -05:00
parent 9e3eefee6a
commit 85ed00a547
Signed by: daylin
GPG key ID: 950D13E9719334AD
5 changed files with 23 additions and 15 deletions

View file

@ -3,7 +3,7 @@ package cmd
import (
"os"
o "oizys/pkg"
o "oizys/internal"
cc "github.com/ivanpirog/coloredcobra"
"github.com/spf13/cobra"

View file

@ -11,7 +11,7 @@ buildGoModule {
version = "unstable";
src = lib.cleanSource ./.;
vendorHash = "sha256-NCHU491j6fRfSk6LA9tS9yiuT/gZhPic46mNTVf1Jeg=";
vendorHash = "sha256-9dfEWPq4dVksv7b2TobnWUc3MwMnKEA40UVTDOSDREg=";
nativeBuildInputs = [
installShellFiles

View file

@ -4,21 +4,23 @@ go 1.22.2
require (
github.com/briandowns/spinner v1.23.0
github.com/charmbracelet/lipgloss v0.11.0
github.com/ivanpirog/coloredcobra v1.0.1
github.com/muesli/termenv v0.15.2
github.com/spf13/cobra v1.8.0
golang.org/x/term v0.19.0
)
require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/x/ansi v0.1.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/sys v0.20.0 // indirect
)

View file

@ -2,6 +2,10 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiE
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/briandowns/spinner v1.23.0 h1:alDF2guRWqa/FOZZYWjlMIx2L6H0wyewPxo/CH4Pt2A=
github.com/briandowns/spinner v1.23.0/go.mod h1:rPG4gmXeN3wQV/TsAY4w8lPdIM6RX3yqeBQJSrbXjuE=
github.com/charmbracelet/lipgloss v0.11.0 h1:UoAcbQ6Qml8hDwSWs0Y1cB5TEQuZkDPH/ZqwWWYTG4g=
github.com/charmbracelet/lipgloss v0.11.0/go.mod h1:1UdRTH9gYgpcdNN5oBtjbu/IzNKtzVtb7sqN1t9LNn8=
github.com/charmbracelet/x/ansi v0.1.1 h1:CGAduulr6egay/YVbGc8Hsu8deMg1xZ/bkaXTPi1JDk=
github.com/charmbracelet/x/ansi v0.1.1/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
@ -40,8 +44,8 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

View file

@ -10,7 +10,7 @@ import (
"strings"
"time"
"github.com/muesli/termenv"
"github.com/charmbracelet/lipgloss"
"golang.org/x/term"
"github.com/briandowns/spinner"
@ -24,7 +24,6 @@ type Oizys struct {
verbose bool
}
var output = termenv.NewOutput(os.Stdout)
func NewOizys() *Oizys {
hostname, err := os.Hostname()
@ -137,7 +136,10 @@ func (p *packages) show(verbose bool) {
func (p *packages) summary() {
fmt.Printf("%s: %s\n",
p.desc,
output.String(fmt.Sprint(len(p.names))).Bold().Foreground(output.Color("6")),
lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("6")).
Render(fmt.Sprint(len(p.names))),
)
}
@ -151,7 +153,7 @@ func (o *Oizys) git(rest ...string) *exec.Cmd {
}
func showFailedOutput(buf []byte) {
arrow := output.String("->").Bold().Foreground(output.Color("9"))
arrow := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("9")).Render("->")
for _, line := range strings.Split(strings.TrimSpace(string(buf)), "\n") {
fmt.Println(arrow, line)
}
@ -288,7 +290,7 @@ func Output(flake string, host string) string {
func nixSpinner(host string) *spinner.Spinner {
msg := fmt.Sprintf("%s %s", " evaluating derivation for:",
output.String(host).Bold().Foreground(output.Color("6")),
lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("6")).Render(host),
)
s := spinner.New(
spinner.CharSets[14],