Skip to content
Permalink
Browse files
Handle newline/spaces in prompt for username
  • Loading branch information
geomacy committed Jul 4, 2017
1 parent fffaec0 commit b73bc2d5a7973aabe42422ba211036372e72e5db
Showing 1 changed file with 10 additions and 6 deletions.
@@ -83,13 +83,17 @@ func (cmd *Login) Run(scope scope.Scope, c *cli.Context) {

// Prompt for username if not supplied
if cmd.network.BrooklynUser == "" {
reader := bufio.NewReader(os.Stdin)
fmt.Print("Enter Username: ")
user, err := reader.ReadString('\n')
if err != nil {
error_handler.ErrorExit(err)
var userName string
for userName == "" {
reader := bufio.NewReader(os.Stdin)
fmt.Print("Enter Username: ")
user, err := reader.ReadString('\n')
if err != nil {
error_handler.ErrorExit(err)
}
userName = strings.TrimSpace(user)
}
cmd.network.BrooklynUser = strings.TrimSpace(user)
cmd.network.BrooklynUser = userName
}

// Prompt for password if not supplied (password is not echoed to screen

0 comments on commit b73bc2d

Please sign in to comment.