Make password prompt compatible with Windows
This commit is contained in:
parent
87648490fd
commit
61bfb3cfa8
7 changed files with 15 additions and 3 deletions
|
@ -14,13 +14,23 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func askCredentials() (string, string) {
|
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: ")
|
fmt.Print("Enter Username: ")
|
||||||
|
|
||||||
|
reader := bufio.NewReader(os.Stdin)
|
||||||
username, _ := reader.ReadString('\n')
|
username, _ := reader.ReadString('\n')
|
||||||
|
|
||||||
fmt.Print("Enter Password: ")
|
fmt.Print("Enter Password: ")
|
||||||
bytePassword, _ := terminal.ReadPassword(0)
|
|
||||||
|
state, _ := terminal.GetState(fd)
|
||||||
|
defer terminal.Restore(fd, state)
|
||||||
|
bytePassword, _ := terminal.ReadPassword(fd)
|
||||||
|
|
||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
return strings.TrimSpace(username), strings.TrimSpace(string(bytePassword))
|
return strings.TrimSpace(username), strings.TrimSpace(string(bytePassword))
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -11,7 +11,7 @@ require (
|
||||||
github.com/lib/pq v1.0.0
|
github.com/lib/pq v1.0.0
|
||||||
github.com/tdewolff/minify v2.3.5+incompatible // indirect
|
github.com/tdewolff/minify v2.3.5+incompatible // indirect
|
||||||
github.com/tdewolff/parse v2.3.3+incompatible // indirect
|
github.com/tdewolff/parse v2.3.3+incompatible // indirect
|
||||||
golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac
|
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -20,6 +20,8 @@ golang.org/x/crypto v0.0.0-20180621125126-a49355c7e3f8 h1:h7zdf0RiEvWbYBKIx4b+q4
|
||||||
golang.org/x/crypto v0.0.0-20180621125126-a49355c7e3f8/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20180621125126-a49355c7e3f8/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac h1:7d7lG9fHOLdL6jZPtnV4LpI41SbohIJ1Atq7U991dMg=
|
golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac h1:7d7lG9fHOLdL6jZPtnV4LpI41SbohIJ1Atq7U991dMg=
|
||||||
golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
|
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 h1:mKdxBk7AujPs8kU4m80U72y/zjbZ3UcXC7dClwKbUI0=
|
||||||
|
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180706051357-32a936f46389 h1:U+zCn5sqaq+q4hrnMrz9sgrW1yatwEOUgYkGt3u9ZOU=
|
golang.org/x/net v0.0.0-20180706051357-32a936f46389 h1:U+zCn5sqaq+q4hrnMrz9sgrW1yatwEOUgYkGt3u9ZOU=
|
||||||
golang.org/x/net v0.0.0-20180706051357-32a936f46389/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180706051357-32a936f46389/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
|
0
locale/locale.go
Executable file → Normal file
0
locale/locale.go
Executable file → Normal file
0
locale/translations.go
Executable file → Normal file
0
locale/translations.go
Executable file → Normal file
0
locale/translations/pl_PL.json
Executable file → Normal file
0
locale/translations/pl_PL.json
Executable file → Normal file
Binary file not shown.
Loading…
Reference in a new issue