File tree 3 files changed +20
-3
lines changed
3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 8
8
9
9
"github.com/bgentry/speakeasy"
10
10
"github.com/codegangsta/cli"
11
- "github.com/heroku/hk/term"
12
11
"github.com/modouwifi/md/api"
13
12
)
14
13
@@ -42,7 +41,7 @@ func runLogout(c *cli.Context) {
42
41
}
43
42
44
43
func readPassword (prompt string ) (password string , err error ) {
45
- if acceptPasswordFromStdin && ! term . IsTerminal (os .Stdin ) {
44
+ if acceptPasswordFromStdin && ! IsTerminal (os .Stdin ) {
46
45
_ , err = fmt .Scanln (& password )
47
46
return
48
47
}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ package main
4
4
import (
5
5
"fmt"
6
6
"os"
7
+ "os/exec"
7
8
)
8
9
9
10
const (
@@ -19,3 +20,10 @@ func homePath() (string, error) {
19
20
20
21
return home , nil
21
22
}
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
+ }
Original file line number Diff line number Diff line change 1
1
// +build windows
2
2
package main
3
3
4
- import "os/user"
4
+ import (
5
+ "os"
6
+ "os/user"
7
+ "syscall"
8
+ )
5
9
6
10
const (
7
11
acceptPasswordFromStdin = false
@@ -15,3 +19,9 @@ func homePath() (string, error) {
15
19
}
16
20
return u .HomeDir , nil
17
21
}
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
+ }
You can’t perform that action at this time.
0 commit comments