Skip to content

Commit

Permalink
Merge pull request #62 from nabbar/fix_promptpassword
Browse files Browse the repository at this point in the history
fixed PromptPassword
  • Loading branch information
Nicolas JUHEL authored Sep 22, 2020
2 parents 09648d4 + 8160794 commit 80c078b
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions console/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"net/url"
"os"
"strconv"
"syscall"

"golang.org/x/crypto/ssh/terminal"
)
Expand Down Expand Up @@ -84,21 +85,9 @@ func PromptBool(text string) (bool, error) {
}

func PromptPassword(text string) (string, error) {
var (
res string
err error
)

printPrompt(text)
res, err = getTerminal().ReadPassword("")
res, err := terminal.ReadPassword(int(syscall.Stdin))
fmt.Printf("\n")

return res, err
}

func getTerminal() *terminal.Terminal {
r := bufio.NewReader(os.Stdin)
w := bufio.NewWriter(os.Stdout)
b := bufio.NewReadWriter(r, w)
return terminal.NewTerminal(b, "")
return string(res), err
}

0 comments on commit 80c078b

Please sign in to comment.