Browse code

highlight current project with asterisk

juanvallejo authored on 2016/06/21 02:34:58
Showing 2 changed files
... ...
@@ -318,6 +318,7 @@ func (o *LoginOptions) gatherProjectInfo() error {
318 318
 
319 319
 	case 1:
320 320
 		o.Project = projectsItems[0].Name
321
+		fmt.Fprintf(o.Out, "You have one project on this server: %q\n\n", o.Project)
321 322
 		fmt.Fprintf(o.Out, "Using project %q.\n", o.Project)
322 323
 
323 324
 	default:
... ...
@@ -344,9 +345,9 @@ func (o *LoginOptions) gatherProjectInfo() error {
344 344
 		fmt.Fprintf(o.Out, "You have access to the following projects and can switch between them with 'oc project <projectname>':\n\n")
345 345
 		for _, p := range projects.List() {
346 346
 			if o.Project == p {
347
-				fmt.Fprintf(o.Out, "  * %s (current)\n", p)
348
-			} else {
349 347
 				fmt.Fprintf(o.Out, "  * %s\n", p)
348
+			} else {
349
+				fmt.Fprintf(o.Out, "    %s\n", p)
350 350
 			}
351 351
 		}
352 352
 		fmt.Fprintln(o.Out)
... ...
@@ -113,20 +113,22 @@ func (o ProjectsOptions) RunProjects() error {
113 113
 	defaultContextName := cliconfig.GetContextNickname(currentContext.Namespace, currentContext.Cluster, currentContext.AuthInfo)
114 114
 
115 115
 	var msg string
116
-	var current string
117 116
 	projects, err := getProjects(client)
118 117
 	if err == nil {
119 118
 		switch len(projects) {
120 119
 		case 0:
121 120
 			msg += "You are not a member of any projects. You can request a project to be created with the 'new-project' command."
122 121
 		case 1:
123
-			msg += fmt.Sprintf("You have one project on this server: %q.", api.DisplayNameAndNameForProject(&projects[0]))
122
+			if o.DisplayShort {
123
+				msg += fmt.Sprintf("%s", api.DisplayNameAndNameForProject(&projects[0]))
124
+			} else {
125
+				msg += fmt.Sprintf("You have one project on this server: %q.", api.DisplayNameAndNameForProject(&projects[0]))
126
+			}
124 127
 		default:
125 128
 			asterisk := ""
126 129
 			count := 0
127 130
 			if !o.DisplayShort {
128 131
 				msg += "You have access to the following projects and can switch between them with 'oc project <projectname>':\n"
129
-				asterisk = "  * "
130 132
 			}
131 133
 			for _, project := range projects {
132 134
 				count = count + 1
... ...
@@ -136,17 +138,19 @@ func (o ProjectsOptions) RunProjects() error {
136 136
 					displayName = project.Annotations["displayName"]
137 137
 				}
138 138
 
139
-				current = ""
140
-				if currentProjectExists && currentProject == project.Name && !o.DisplayShort {
141
-					current = " (current)"
139
+				if currentProjectExists && !o.DisplayShort {
140
+					asterisk = "    "
141
+					if currentProject == project.Name {
142
+						asterisk = "  * "
143
+					}
142 144
 				}
143 145
 				if len(displayName) > 0 && displayName != project.Name && !o.DisplayShort {
144
-					msg += fmt.Sprintf("\n  * %s (%s)%s", displayName, project.Name, current)
146
+					msg += fmt.Sprintf("\n  "+asterisk+"%s (%s)", displayName, project.Name)
145 147
 				} else {
146 148
 					if o.DisplayShort && count == 1 {
147 149
 						linebreak = ""
148 150
 					}
149
-					msg += fmt.Sprintf(linebreak+asterisk+"%s%s", project.Name, current)
151
+					msg += fmt.Sprintf(linebreak+asterisk+"%s", project.Name)
150 152
 				}
151 153
 			}
152 154
 		}