brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjcorb...@apache.org
Subject [04/18] brooklyn-client git commit: Handle newline/spaces in prompt for username
Date Mon, 17 Jul 2017 12:06:11 GMT
Handle newline/spaces in prompt for username


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-client/commit/b73bc2d5
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-client/tree/b73bc2d5
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-client/diff/b73bc2d5

Branch: refs/heads/master
Commit: b73bc2d5a7973aabe42422ba211036372e72e5db
Parents: fffaec0
Author: Geoff Macartney <geoff.macartney@cloudsoftcorp.com>
Authored: Tue May 23 17:08:15 2017 +0100
Committer: Geoff Macartney <geoff.macartney@cloudsoftcorp.com>
Committed: Tue Jul 4 11:06:00 2017 +0100

----------------------------------------------------------------------
 cli/commands/login.go | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/b73bc2d5/cli/commands/login.go
----------------------------------------------------------------------
diff --git a/cli/commands/login.go b/cli/commands/login.go
index b2ab208..84e13b3 100644
--- a/cli/commands/login.go
+++ b/cli/commands/login.go
@@ -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


Mime
View raw message