Drop another dependency
This commit is contained in:
parent
cf287015de
commit
eb4ee13f73
1
go.mod
1
go.mod
@ -3,7 +3,6 @@ module kitty
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/mattn/go-isatty v0.0.14
|
||||
github.com/mattn/go-runewidth v0.0.13
|
||||
github.com/seancfoley/ipaddress-go v1.2.1
|
||||
github.com/spf13/cobra v1.5.0
|
||||
|
||||
2
go.sum
2
go.sum
@ -1,8 +1,6 @@
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
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-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
|
||||
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||
|
||||
@ -10,13 +10,13 @@ import (
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/mattn/go-isatty"
|
||||
"github.com/mattn/go-runewidth"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"kitty"
|
||||
"kitty/tools/tty"
|
||||
"kitty/tools/utils"
|
||||
)
|
||||
|
||||
@ -488,7 +488,7 @@ func Init(root *cobra.Command) {
|
||||
if kitty.VCSRevision != "" {
|
||||
vs = vs + " (" + kitty.VCSRevision + ")"
|
||||
}
|
||||
stdout_is_terminal = isatty.IsTerminal(os.Stdout.Fd())
|
||||
stdout_is_terminal = tty.IsTerminal(os.Stdout.Fd())
|
||||
RootCmd = root
|
||||
root.Version = vs
|
||||
root.SetUsageFunc(func(cmd *cobra.Command) error { return show_usage(cmd, false) })
|
||||
|
||||
@ -9,7 +9,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mattn/go-isatty"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
"golang.org/x/sys/unix"
|
||||
@ -254,7 +253,7 @@ func get_password(password string, password_file string, password_env string, us
|
||||
}
|
||||
if ans == "" && password_file != "" {
|
||||
if password_file == "-" {
|
||||
if isatty.IsTerminal(os.Stdin.Fd()) {
|
||||
if tty.IsTerminal(os.Stdin.Fd()) {
|
||||
q, err := term.ReadPassword(int(os.Stdin.Fd()))
|
||||
if err != nil {
|
||||
ans = string(q)
|
||||
|
||||
@ -19,6 +19,12 @@ const (
|
||||
TCSAFLUSH = 2
|
||||
)
|
||||
|
||||
func IsTerminal(fd uintptr) bool {
|
||||
var t unix.Termios
|
||||
err := Tcgetattr(int(fd), &t)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
type Term struct {
|
||||
name string
|
||||
fd int
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user