Write username and password prompt to stderr

This commit is contained in:
Marcel Transier 2019-10-11 16:12:26 +02:00
parent ddbfc6893a
commit 13c28408f9
2 changed files with 3 additions and 4 deletions

View File

@ -8,4 +8,3 @@ or LSF Served Fabulously
- tests - tests
- webapi - webapi
- wrap errors correctly. run cmd/lsf without an internet connection and get inspired by the standard libary - wrap errors correctly. run cmd/lsf without an internet connection and get inspired by the standard libary
- username/password prompt stderr

View File

@ -74,7 +74,7 @@ func sessionNeeded() {
func readUsername() (string, error) { func readUsername() (string, error) {
var username string var username string
fmt.Print("Username: ") fmt.Fprint(os.Stderr, "Username: ")
_, err := fmt.Scanf("%s", &username) _, err := fmt.Scanf("%s", &username)
if err != nil { if err != nil {
return "", errors.Wrap(err, "could not read username") return "", errors.Wrap(err, "could not read username")
@ -84,12 +84,12 @@ func readUsername() (string, error) {
func readPassword() (string, error) { func readPassword() (string, error) {
var password string var password string
fmt.Print("Password: ") fmt.Fprint(os.Stderr, "Password: ")
b, err := terminal.ReadPassword(int(syscall.Stdin)) b, err := terminal.ReadPassword(int(syscall.Stdin))
if err != nil { if err != nil {
return "", err return "", err
} }
fmt.Print("\n") fmt.Fprint(os.Stderr, "\n")
password = string(b) password = string(b)
return password, nil return password, nil
} }