func actionUserPasswd(c *cli.Context) { api, user := mustUserAPIAndName(c) ctx, cancel := context.WithTimeout(context.Background(), client.DefaultRequestTimeout) currentUser, err := api.GetUser(ctx, user) cancel() if currentUser == nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(1) } pass, err := speakeasy.Ask("New password: "******"Error reading password:"******"Password updated\n") }
func main() { password, err := speakeasy.Ask("Please enter a password: "******"Password result: %q\n", password) fmt.Printf("Password len: %d\n", len(password)) }
func getUsernamePasswordFromFlag(usernameFlag string) (username string, password string, err error) { colon := strings.Index(usernameFlag, ":") if colon == -1 { username = usernameFlag // Prompt for the password. password, err = speakeasy.Ask("Password: "******"", "", err } } else { username = usernameFlag[:colon] password = usernameFlag[colon+1:] } return username, password, nil }
func actionUserAdd(c *cli.Context) { api, user := mustUserAPIAndName(c) ctx, cancel := contextWithTotalTimeout(c) defer cancel() currentUser, err := api.GetUser(ctx, user) if currentUser != nil { fmt.Fprintf(os.Stderr, "User %s already exists\n", user) os.Exit(1) } pass, err := speakeasy.Ask("New password: "******"Error reading password:"******"User %s created\n", user) }
func actionUserPasswd(c *cli.Context) { api, user := mustUserAPIAndName(c) ctx, cancel := contextWithTotalTimeout(c) defer cancel() currentUser, err := api.GetUser(ctx, user) if currentUser == nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(1) } pass, err := speakeasy.Ask("New password: "******"Error reading password:"******"Password updated\n") }