ask_credentials.go 587 B

123456789101112131415161718192021222324252627
  1. // Copyright 2018 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package cli
  5. import (
  6. "bufio"
  7. "fmt"
  8. "os"
  9. "strings"
  10. "golang.org/x/crypto/ssh/terminal"
  11. )
  12. func askCredentials() (string, string) {
  13. reader := bufio.NewReader(os.Stdin)
  14. fmt.Print("Enter Username: ")
  15. username, _ := reader.ReadString('\n')
  16. fmt.Print("Enter Password: ")
  17. bytePassword, _ := terminal.ReadPassword(0)
  18. fmt.Printf("\n")
  19. return strings.TrimSpace(username), strings.TrimSpace(string(bytePassword))
  20. }