Sagi Dayan
d5d1eecb89
Some checks failed
Codespell / Check for spelling errors (push) Failing after 1m26s
Signed-off-by: Sagi Dayan <sagidayan@gmail.com>
23 lines
295 B
Go
23 lines
295 B
Go
package prompt
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"syscall"
|
|
|
|
"golang.org/x/term"
|
|
)
|
|
|
|
func PasswordPrompt(label string) string {
|
|
var s string
|
|
for {
|
|
fmt.Fprint(os.Stderr, label+" ")
|
|
b, _ := term.ReadPassword(int(syscall.Stdin))
|
|
s = string(b)
|
|
if s != "" {
|
|
break
|
|
}
|
|
}
|
|
fmt.Println()
|
|
return s
|
|
}
|