Skip to content

Commit 2fd4eee

Browse files
committed
remove hk/term
1 parent 54d9e8f commit 2fd4eee

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

auth.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88

99
"github.com/bgentry/speakeasy"
1010
"github.com/codegangsta/cli"
11-
"github.com/heroku/hk/term"
1211
"github.com/modouwifi/md/api"
1312
)
1413

@@ -42,7 +41,7 @@ func runLogout(c *cli.Context) {
4241
}
4342

4443
func readPassword(prompt string) (password string, err error) {
45-
if acceptPasswordFromStdin && !term.IsTerminal(os.Stdin) {
44+
if acceptPasswordFromStdin && !IsTerminal(os.Stdin) {
4645
_, err = fmt.Scanln(&password)
4746
return
4847
}

unix.go

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package main
44
import (
55
"fmt"
66
"os"
7+
"os/exec"
78
)
89

910
const (
@@ -19,3 +20,10 @@ func homePath() (string, error) {
1920

2021
return home, nil
2122
}
23+
24+
// IsTerminal returns true if f is a terminal.
25+
func IsTerminal(f *os.File) bool {
26+
cmd := exec.Command("test", "-t", "0")
27+
cmd.Stdin = f
28+
return cmd.Run() == nil
29+
}

windows.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
// +build windows
22
package main
33

4-
import "os/user"
4+
import (
5+
"os"
6+
"os/user"
7+
"syscall"
8+
)
59

610
const (
711
acceptPasswordFromStdin = false
@@ -15,3 +19,9 @@ func homePath() (string, error) {
1519
}
1620
return u.HomeDir, nil
1721
}
22+
23+
// IsTerminal returns false on Windows.
24+
func IsTerminal(f *os.File) bool {
25+
ft, _ := syscall.GetFileType(syscall.Handle(f.Fd()))
26+
return ft == syscall.FILE_TYPE_CHAR
27+
}

0 commit comments

Comments
 (0)