starting 0.0.2 dev
This commit is contained in:
26
cmd/cli/tools/prompt/credentials/credentials.go
Normal file
26
cmd/cli/tools/prompt/credentials/credentials.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package credentials
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
func Read() (string, string, error) {
|
||||
fmt.Print("Enter username: ")
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
username, _ := reader.ReadString('\n')
|
||||
username = strings.TrimSpace(username)
|
||||
|
||||
fmt.Printf("password for %s: ", username)
|
||||
password, err := term.ReadPassword(int(os.Stdin.Fd()))
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
fmt.Println()
|
||||
|
||||
return username, string(password), nil
|
||||
}
|
||||
Reference in New Issue
Block a user