PromptPassword prompts the user input a password and saves the result to the destination. The input is masked, meaning it is not echoed on the terminal.
(message string, dest *string)
| 55 | // PromptPassword prompts the user input a password and saves the result to the destination. |
| 56 | // The input is masked, meaning it is not echoed on the terminal. |
| 57 | func PromptPassword(message string, dest *string) error { |
| 58 | log.Askf(message, true) |
| 59 | |
| 60 | password, err := terminal.ReadPassword(int(syscall.Stdin)) |
| 61 | if err != nil { |
| 62 | return errors.Wrap(err, "getting user input") |
| 63 | } |
| 64 | |
| 65 | fmt.Println("") |
| 66 | |
| 67 | *dest = string(password) |
| 68 | |
| 69 | return nil |
| 70 | } |
| 71 | |
| 72 | // Confirm prompts for user input to confirm a choice |
| 73 | func Confirm(question string, optimistic bool) (bool, error) { |