Get rid of a couple of unneeded dependencies

This commit is contained in:
Kovid Goyal 2022-08-20 16:54:21 +05:30
parent 11ffa961bc
commit 08b4741024
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 36 additions and 21 deletions

2
go.mod
View File

@ -3,7 +3,6 @@ module kitty
go 1.19 go 1.19
require ( require (
github.com/fatih/color v1.13.0
github.com/mattn/go-isatty v0.0.14 github.com/mattn/go-isatty v0.0.14
github.com/mattn/go-runewidth v0.0.13 github.com/mattn/go-runewidth v0.0.13
github.com/pkg/term v1.1.0 github.com/pkg/term v1.1.0
@ -17,7 +16,6 @@ require (
require ( require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/rivo/uniseg v0.2.0 // indirect github.com/rivo/uniseg v0.2.0 // indirect
github.com/seancfoley/bintree v1.1.0 // indirect github.com/seancfoley/bintree v1.1.0 // indirect
) )

7
go.sum
View File

@ -1,11 +1,6 @@
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
@ -25,8 +20,6 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=

View File

@ -10,7 +10,6 @@ import (
"strings" "strings"
"unicode" "unicode"
"github.com/fatih/color"
"github.com/mattn/go-isatty" "github.com/mattn/go-isatty"
runewidth "github.com/mattn/go-runewidth" runewidth "github.com/mattn/go-runewidth"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -75,17 +74,42 @@ func ChoicesP(flags *pflag.FlagSet, name string, short string, usage string, cho
} }
var stdout_is_terminal = false var stdout_is_terminal = false
var title_fmt = color.New(color.FgBlue, color.Bold).SprintFunc()
var exe_fmt = color.New(color.FgYellow, color.Bold).SprintFunc() func surrounder(start int, end int) func(string) string {
var opt_fmt = color.New(color.FgGreen).SprintFunc() return func(text string) string {
var italic_fmt = color.New(color.Italic).SprintFunc() if stdout_is_terminal {
var err_fmt = color.New(color.FgHiRed).SprintFunc() return fmt.Sprintf("\033[%dm%s\033[%dm", start, text, end)
var bold_fmt = color.New(color.Bold).SprintFunc() }
var code_fmt = color.New(color.FgCyan).SprintFunc() return text
var cyan_fmt = color.New(color.FgCyan).SprintFunc() }
var yellow_fmt = color.New(color.FgYellow).SprintFunc() }
var blue_fmt = color.New(color.FgBlue).SprintFunc()
var green_fmt = color.New(color.FgGreen).SprintFunc() func compose_surrounders(surrounders ...func(string) string) func(string) string {
return func(text string) string {
if stdout_is_terminal {
for _, surrounder := range surrounders {
text = surrounder(text)
}
}
return text
}
}
var (
emph_fmt = surrounder(91, 39)
cyan_fmt = surrounder(96, 39)
green_fmt = surrounder(32, 39)
blue_fmt = surrounder(34, 39)
bright_red_fmt = surrounder(91, 39)
yellow_fmt = surrounder(93, 39)
italic_fmt = surrounder(3, 23)
bold_fmt = surrounder(1, 22)
title_fmt = compose_surrounders(blue_fmt, bold_fmt)
exe_fmt = compose_surrounders(yellow_fmt, bold_fmt)
opt_fmt = green_fmt
err_fmt = compose_surrounders(bright_red_fmt, bold_fmt)
code_fmt = cyan_fmt
)
func format_line_with_indent(output io.Writer, text string, indent string, screen_width int) { func format_line_with_indent(output io.Writer, text string, indent string, screen_width int) {
trimmed := strings.TrimSpace(text) trimmed := strings.TrimSpace(text)