Skip to content

Commit

Permalink
Handle newline/spaces in prompt for username
Browse files Browse the repository at this point in the history
  • Loading branch information
geomacy committed Jul 4, 2017
1 parent fffaec0 commit b73bc2d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions cli/commands/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b73bc2d

Please sign in to comment.