Skip to content

Commit

Permalink
cmd/age: use golang.org/x/term instead of deprecated package (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
codesoap committed Apr 5, 2021
1 parent dabc470 commit bad2c0d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions cmd/age-keygen/keygen.go
Expand Up @@ -16,7 +16,7 @@ import (
"time"

"filippo.io/age"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/term"
)

const usage = `Usage:
Expand Down Expand Up @@ -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())
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/age/age.go
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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{}
Expand Down
6 changes: 3 additions & 3 deletions cmd/age/encrypted_keys.go
Expand Up @@ -12,7 +12,7 @@ import (
"os"

"filippo.io/age"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/term"
)

type LazyScryptIdentity struct {
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Expand Up @@ -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
)

0 comments on commit bad2c0d

Please sign in to comment.