Files
cloudsave/cmd/cli/tools/prompt/credentials/credentials.go
2025-07-30 00:49:22 +02:00

27 lines
473 B
Go

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
}