2020-05-12 11:01:02 -04:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2020-05-20 18:23:22 +03:00
|
|
|
|
|
|
|
"golang.org/x/crypto/ssh/terminal"
|
2020-05-12 11:01:02 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// PasswordReader reads a password from a mock or stdin.
|
|
|
|
type PasswordReader interface {
|
|
|
|
ReadPassword() (string, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// StdInPasswordReader reads a password from stdin.
|
|
|
|
type StdInPasswordReader struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
// ReadPassword reads a password from stdin.
|
2021-12-07 18:52:39 +01:00
|
|
|
func (_ StdInPasswordReader) ReadPassword() (string, error) {
|
2020-09-14 12:49:15 +02:00
|
|
|
pwd, err := terminal.ReadPassword(int(os.Stdin.Fd()))
|
|
|
|
return string(pwd), err
|
2020-05-12 11:01:02 -04:00
|
|
|
}
|