mirror of
https://github.com/FiloSottile/age.git
synced 2026-03-11 08:55:41 +00:00
cmd/age: use golang.org/x/term instead of deprecated package (#205)
This commit is contained in:
parent
dabc470bfe
commit
bad2c0d2e0
4 changed files with 12 additions and 9 deletions
|
|
@ -16,7 +16,7 @@ import (
|
|||
"time"
|
||||
|
||||
"filippo.io/age"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
const usage = `Usage:
|
||||
|
|
@ -127,7 +127,7 @@ func generate(out *os.File) {
|
|||
log.Fatalf("Internal error: %v", err)
|
||||
}
|
||||
|
||||
if !terminal.IsTerminal(int(out.Fd())) {
|
||||
if !term.IsTerminal(int(out.Fd())) {
|
||||
fmt.Fprintf(os.Stderr, "Public key: %s\n", k.Recipient())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import (
|
|||
"filippo.io/age"
|
||||
"filippo.io/age/agessh"
|
||||
"filippo.io/age/armor"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
type multiFlag []string
|
||||
|
|
@ -186,7 +186,7 @@ func main() {
|
|||
f := newLazyOpener(name)
|
||||
defer f.Close()
|
||||
out = f
|
||||
} else if terminal.IsTerminal(int(os.Stdout.Fd())) {
|
||||
} else if term.IsTerminal(int(os.Stdout.Fd())) {
|
||||
if name != "-" {
|
||||
if decryptFlag {
|
||||
// TODO: buffer the output and check it's printable.
|
||||
|
|
@ -197,7 +197,7 @@ func main() {
|
|||
`Did you mean to use -a/--armor? Force with "-o -".`)
|
||||
}
|
||||
}
|
||||
if in == os.Stdin && terminal.IsTerminal(int(os.Stdin.Fd())) {
|
||||
if in == os.Stdin && term.IsTerminal(int(os.Stdin.Fd())) {
|
||||
// If the input comes from a TTY and output will go to a TTY,
|
||||
// buffer it up so it doesn't get in the way of typing the input.
|
||||
buf := &bytes.Buffer{}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
"os"
|
||||
|
||||
"filippo.io/age"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
type LazyScryptIdentity struct {
|
||||
|
|
@ -50,7 +50,7 @@ var stdinInUse bool
|
|||
|
||||
func readPassphrase() ([]byte, error) {
|
||||
fd := int(os.Stdin.Fd())
|
||||
if !terminal.IsTerminal(fd) || stdinInUse {
|
||||
if !term.IsTerminal(fd) || stdinInUse {
|
||||
tty, err := os.Open("/dev/tty")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("standard input is not available or not a terminal, and opening /dev/tty failed: %v", err)
|
||||
|
|
@ -59,7 +59,7 @@ func readPassphrase() ([]byte, error) {
|
|||
fd = int(tty.Fd())
|
||||
}
|
||||
defer fmt.Fprintf(os.Stderr, "\n")
|
||||
p, err := terminal.ReadPassword(fd)
|
||||
p, err := term.ReadPassword(fd)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
5
go.mod
5
go.mod
|
|
@ -2,4 +2,7 @@ module filippo.io/age
|
|||
|
||||
go 1.13
|
||||
|
||||
require golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
|
||||
require (
|
||||
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue