InteractiveCredentials asks for username/password when no such credentials were configured
()
| 9 | |
| 10 | // InteractiveCredentials asks for username/password when no such credentials were configured |
| 11 | func ( c *Client ) InteractiveCredentials() ( err error ) { |
| 12 | if ! terminal.IsTerminal( syscall.Stdin ) { return errors.New( "not a terminal" ) } |
| 13 | if len( c.Config.Username ) == 0 { |
| 14 | fmt.Print( "Username: " ) |
| 15 | if _, err = fmt.Scanln( &c.Config.Username ); err != nil { return } |
| 16 | } |
| 17 | if len( c.Config.Password ) == 0 { |
| 18 | fmt.Print( "Password: " ) |
| 19 | if passwordBytes, err := terminal.ReadPassword( syscall.Stdin ); err != nil { fmt.Println() } else { fmt.Println(); c.Config.Password = string( passwordBytes ) } |
| 20 | } |
| 21 | return |
| 22 | } |