2020-05-12 15:01:02 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2020-05-20 15:23:22 +00:00
|
|
|
|
|
|
|
"golang.org/x/crypto/ssh/terminal"
|
2020-05-12 15:01:02 +00: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.
|
|
|
|
func (pr StdInPasswordReader) ReadPassword() (string, error) {
|
2020-09-14 10:49:15 +00:00
|
|
|
pwd, err := terminal.ReadPassword(int(os.Stdin.Fd()))
|
|
|
|
return string(pwd), err
|
2020-05-12 15:01:02 +00:00
|
|
|
}
|