1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-06 17:41:00 +00:00

Make password prompt compatible with Windows

This commit is contained in:
Frederic Guillot 2018-12-09 17:44:33 -08:00
parent 87648490fd
commit 61bfb3cfa8
7 changed files with 15 additions and 3 deletions

View file

@ -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))