|
|
@@ -14,13 +14,23 @@ import (
|
|
|
)
|
|
|
|
|
|
func askCredentials() (string, string) {
|
|
|
- reader := bufio.NewReader(os.Stdin)
|
|
|
+ fd := int(os.Stdin.Fd())
|
|
|
+
|
|
|
+ if !terminal.IsTerminal(fd) {
|
|
|
+ fmt.Fprintf(os.Stderr, "This is not a terminal, exiting.")
|
|
|
+ os.Exit(1)
|
|
|
+ }
|
|
|
|
|
|
fmt.Print("Enter Username: ")
|
|
|
+
|
|
|
+ reader := bufio.NewReader(os.Stdin)
|
|
|
username, _ := reader.ReadString('\n')
|
|
|
|
|
|
fmt.Print("Enter Password: ")
|
|
|
- bytePassword, _ := terminal.ReadPassword(0)
|
|
|
+
|
|
|
+ state, _ := terminal.GetState(fd)
|
|
|
+ defer terminal.Restore(fd, state)
|
|
|
+ bytePassword, _ := terminal.ReadPassword(fd)
|
|
|
|
|
|
fmt.Printf("\n")
|
|
|
return strings.TrimSpace(username), strings.TrimSpace(string(bytePassword))
|