Skip to content

Commit fc484ad

Browse files
authored
Align highlight and hyperlink colours with design pattern guide (#4847)
Use ANSI-defined **Bright Blue** and **Bright Cyan** for highlighted content and hyperlinks respectively, after taking into consideration what looks both visually distinct and legible across popular terminal environments and themes.
1 parent dd18a0c commit fc484ad

File tree

11 files changed

+47
-39
lines changed

11 files changed

+47
-39
lines changed

cli/azd/cmd/init.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func (i *initAction) Run(ctx context.Context) (*actions.ActionResult, error) {
221221
tracing.SetUsageAttributes(fields.InitMethod.String("app"))
222222

223223
header = "Your app is ready for the cloud!"
224-
followUp = "You can provision and deploy your app to Azure by running the " + color.BlueString("azd up") +
224+
followUp = "You can provision and deploy your app to Azure by running the " + output.WithHighLightFormat("azd up") +
225225
" command in this directory. For more information on configuring your app, see " +
226226
output.WithHighLightFormat("./next-steps.md")
227227
entries, err := os.ReadDir(azdCtx.ProjectDirectory())
@@ -234,7 +234,7 @@ func (i *initAction) Run(ctx context.Context) (*actions.ActionResult, error) {
234234
Err: errors.New("no files found in the current directory"),
235235
Suggestion: "Ensure you're in the directory where your app code is located and try again." +
236236
" If you do not have code and would like to start with an app template, run '" +
237-
color.BlueString("azd init") + "' and select the option to " +
237+
output.WithHighLightFormat("azd init") + "' and select the option to " +
238238
color.MagentaString("Use a template") + ".",
239239
}
240240
}
@@ -300,7 +300,7 @@ func (i *initAction) Run(ctx context.Context) (*actions.ActionResult, error) {
300300
return nil, fmt.Errorf("saving project config: %w", err)
301301
}
302302

303-
followUp = "Run " + color.BlueString("azd add") + " to add new Azure components to your project."
303+
followUp = "Run " + output.WithHighLightFormat("azd add") + " to add new Azure components to your project."
304304
}
305305

306306
header = "Generated azure.yaml project file."

cli/azd/internal/cmd/add/add.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"github.com/azure/azure-dev/cli/azd/pkg/workflow"
3030
"github.com/azure/azure-dev/cli/azd/pkg/yamlnode"
3131
"github.com/braydonk/yaml"
32-
"github.com/fatih/color"
3332
"github.com/spf13/cobra"
3433
)
3534

@@ -165,8 +164,8 @@ func (a *AddAction) Run(ctx context.Context) (*actions.ActionResult, error) {
165164
resourcesToAdd = append(resourcesToAdd, dep)
166165
requiredByMessages = append(requiredByMessages,
167166
fmt.Sprintf("(%s is required by %s)",
168-
color.BlueString(dep.Name),
169-
color.BlueString(resourceToAdd.Name)))
167+
output.WithHighLightFormat(dep.Name),
168+
output.WithHighLightFormat(resourceToAdd.Name)))
170169
}
171170
}
172171

@@ -203,7 +202,7 @@ func (a *AddAction) Run(ctx context.Context) (*actions.ActionResult, error) {
203202
return nil, fmt.Errorf("re-parsing yaml: %w", err)
204203
}
205204

206-
a.console.Message(ctx, fmt.Sprintf("\nPreviewing changes to %s:\n", color.BlueString("azure.yaml")))
205+
a.console.Message(ctx, fmt.Sprintf("\nPreviewing changes to %s:\n", output.WithHighLightFormat("azure.yaml")))
207206
diffString, diffErr := DiffBlocks(prjConfig.Resources, newCfg.Resources)
208207
if diffErr != nil {
209208
a.console.Message(ctx, "Preview unavailable. Pass --debug for more details.\n")
@@ -273,14 +272,14 @@ func (a *AddAction) Run(ctx context.Context) (*actions.ActionResult, error) {
273272
})
274273
keyVaultFollowUpMessage := fmt.Sprintf(
275274
"\nRun '%s' to add a secret to the key vault.",
276-
color.BlueString("azd env set-secret <name>"))
275+
output.WithHighLightFormat("azd env set-secret <name>"))
277276

278277
if _, err := pathHasInfraModule(infraRoot, prjConfig.Infra.Module); err == nil {
279278
followUpMessage = fmt.Sprintf(
280279
"Run '%s' to re-synthesize the infrastructure, "+
281280
"then run '%s' to provision these changes anytime later.",
282-
color.BlueString("azd infra synth"),
283-
color.BlueString("azd provision"))
281+
output.WithHighLightFormat("azd infra synth"),
282+
output.WithHighLightFormat("azd provision"))
284283
if addedKeyVault {
285284
followUpMessage += keyVaultFollowUpMessage
286285
}
@@ -339,12 +338,12 @@ func (a *AddAction) Run(ctx context.Context) (*actions.ActionResult, error) {
339338
}
340339

341340
followUpMessage = "Run '" +
342-
color.BlueString(fmt.Sprintf("azd show %s", resourceToAdd.Name)) +
341+
output.WithHighLightFormat("azd show %s", resourceToAdd.Name) +
343342
"' to show details about the newly provisioned resource."
344343
} else {
345344
followUpMessage = fmt.Sprintf(
346345
"Run '%s' to %s these changes anytime later.",
347-
color.BlueString("azd %s", followUpCmd),
346+
output.WithHighLightFormat("azd %s", followUpCmd),
348347
verb)
349348
}
350349

cli/azd/internal/cmd/add/add_configure.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/azure/azure-dev/cli/azd/pkg/input"
1515
"github.com/azure/azure-dev/cli/azd/pkg/output"
1616
"github.com/azure/azure-dev/cli/azd/pkg/project"
17-
"github.com/fatih/color"
1817
)
1918

2019
// DbMap is a map of supported database dependencies.
@@ -192,7 +191,7 @@ func fillUses(
192191
labels = formatted
193192
}
194193
uses, err := console.MultiSelect(ctx, input.ConsoleOptions{
195-
Message: fmt.Sprintf("Select the resources that %s uses", color.BlueString(r.Name)),
194+
Message: fmt.Sprintf("Select the resources that %s uses", output.WithHighLightFormat(r.Name)),
196195
Options: labels,
197196
})
198197
if err != nil {

cli/azd/internal/cmd/add/add_preview.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (a *AddAction) previewProvision(
124124
}
125125

126126
a.console.Message(ctx, fmt.Sprintf("\n%s\n", output.WithBold("Previewing Azure resource changes")))
127-
a.console.Message(ctx, "Environment: "+color.BlueString(a.env.Name()))
127+
a.console.Message(ctx, "Environment: "+output.WithHighLightFormat(a.env.Name()))
128128

129129
if environmentDetails.Subscription != "" {
130130
a.console.MessageUxItem(ctx, &environmentDetails)

cli/azd/internal/cmd/show/show.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,8 @@ func showModelDeployment(
424424
if account.Properties.Endpoint != nil {
425425
console.Message(ctx, color.HiMagentaString("%s (Azure AI Services Model Deployment)", id.Name))
426426
console.Message(ctx, " Endpoint:")
427-
console.Message(ctx, color.HiBlueString(fmt.Sprintf(" AZURE_OPENAI_ENDPOINT=%s", *account.Properties.Endpoint)))
427+
console.Message(ctx,
428+
output.WithHighLightFormat(fmt.Sprintf(" AZURE_OPENAI_ENDPOINT=%s", *account.Properties.Endpoint)))
428429
console.Message(ctx, " Access:")
429430
console.Message(ctx, " Keyless (Microsoft Entra ID)")
430431
//nolint:lll

cli/azd/internal/repository/detect_confirm.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func (d *detectConfirm) render(ctx context.Context) error {
198198
status = " " + output.WithSuccessFormat("[Added]")
199199
}
200200

201-
d.console.Message(ctx, " "+color.BlueString(projectDisplayName(svc))+status)
201+
d.console.Message(ctx, " "+output.WithHighLightFormat(projectDisplayName(svc))+status)
202202
d.console.Message(ctx, " "+"Detected in: "+output.WithHighLightFormat(relSafe(d.root, svc.Path)))
203203
d.console.Message(ctx, "")
204204

@@ -224,7 +224,7 @@ func (d *detectConfirm) render(ctx context.Context) error {
224224
status = " " + output.WithSuccessFormat("[Added]")
225225
}
226226

227-
d.console.Message(ctx, " "+color.BlueString(db.Display())+status)
227+
d.console.Message(ctx, " "+output.WithHighLightFormat(db.Display())+status)
228228
d.console.Message(ctx, "")
229229
}
230230

cli/azd/internal/repository/detect_confirm_apphost.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (d *detectConfirmAppHost) Confirm(ctx context.Context) error {
7979
func (d *detectConfirmAppHost) render(ctx context.Context) error {
8080
d.console.Message(ctx, "\n"+output.WithBold("Detected services:")+"\n")
8181

82-
d.console.Message(ctx, " "+color.BlueString(projectDisplayName(d.AppHost)))
82+
d.console.Message(ctx, " "+output.WithHighLightFormat(projectDisplayName(d.AppHost)))
8383
d.console.Message(ctx, " "+"Detected in: "+output.WithHighLightFormat(relSafe(d.root, d.AppHost.Path)))
8484
d.console.Message(ctx, "")
8585
d.console.Message(

cli/azd/pkg/input/asker.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ func askOnePrompt(p survey.Prompt, response interface{}, isTerminal bool, stdout
115115
}
116116

117117
opts = append(opts, survey.WithIcons(func(icons *survey.IconSet) {
118-
// use bold blue question mark for all questions
119-
icons.Question.Format = "blue+b"
120-
icons.SelectFocus.Format = "blue+b"
118+
// use bright, bold, blue question mark for all questions
119+
icons.Question.Format = "blue+hb"
120+
icons.SelectFocus.Format = "blue+hb"
121121

122122
icons.Help.Format = "black+h"
123123
icons.Help.Text = "Hint:"
@@ -247,18 +247,18 @@ func askOnePrompt(p survey.Prompt, response interface{}, isTerminal bool, stdout
247247
}
248248

249249
func init() {
250-
// blue for everything
250+
// bright blue for everything
251251

252252
// Customize the input question template:
253-
// - Use blue instead of cyan for answers: {{- color "blue"}}{{.Answer}}
253+
// - Use bright blue instead of cyan for answers: {{- color "blue+h"}}{{.Answer}}
254254
// - Use gray instead of cyan for default value: {{color "black+h"}}({{.Default}})
255255
//nolint:lll
256256
survey.InputQuestionTemplate = `
257257
{{- if .ShowHelp }}{{- color .Config.Icons.Help.Format }}{{ .Config.Icons.Help.Text }} {{ .Help }}{{color "reset"}}{{"\n"}}{{end}}
258258
{{- color .Config.Icons.Question.Format }}{{ .Config.Icons.Question.Text }} {{color "reset"}}
259259
{{- color "default+hb"}}{{ .Message }} {{color "reset"}}
260260
{{- if .ShowAnswer}}
261-
{{- color "blue"}}{{.Answer}}{{color "reset"}}{{"\n"}}
261+
{{- color "blue+h"}}{{.Answer}}{{color "reset"}}{{"\n"}}
262262
{{- else if .PageEntries -}}
263263
{{- .Answer}} [Use arrows to move, enter to select, type to continue]
264264
{{- "\n"}}
@@ -268,10 +268,20 @@ func init() {
268268
{{- color "reset"}}{{"\n"}}
269269
{{- end}}
270270
{{- else }}
271-
{{- if or (and .Help (not .ShowHelp)) .Suggest }}{{color "cyan"}}[
271+
{{- if or (and .Help (not .ShowHelp)) .Suggest }}{{color "blue+h"}}[
272272
{{- if and .Help (not .ShowHelp)}}{{ print .Config.HelpInput }} for help {{- if and .Suggest}}, {{end}}{{end -}}
273-
{{- if and .Suggest }}{{color "cyan"}}{{ print .Config.SuggestInput }} for suggestions{{end -}}
273+
{{- if and .Suggest }}{{color "blue+h"}}{{ print .Config.SuggestInput }} for suggestions{{end -}}
274274
]{{color "reset"}} {{end}}
275275
{{- if .Default}}{{color "black+h"}}({{.Default}}) {{color "reset"}}{{end}}
276276
{{- end}}`
277+
278+
// Replace cyan with blue in other other templates
279+
otherTemplates := []*string{
280+
&survey.ConfirmQuestionTemplate,
281+
&survey.SelectQuestionTemplate,
282+
&survey.MultiSelectQuestionTemplate,
283+
}
284+
for _, template := range otherTemplates {
285+
*template = strings.ReplaceAll(*template, `"cyan"`, `"blue+h"`)
286+
}
277287
}

cli/azd/pkg/output/colors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func WithLinkFormat(link string, a ...interface{}) string {
1616

1717
// withHighLightFormat creates string with highlight-looking color
1818
func WithHighLightFormat(text string, a ...interface{}) string {
19-
return color.CyanString(text, a...)
19+
return color.HiBlueString(text, a...)
2020
}
2121

2222
func WithErrorFormat(text string, a ...interface{}) string {

cli/azd/pkg/output/ux/environment_details.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"fmt"
99

1010
"github.com/azure/azure-dev/cli/azd/pkg/output"
11-
"github.com/fatih/color"
1211
)
1312

1413
type EnvironmentDetails struct {
@@ -19,11 +18,11 @@ type EnvironmentDetails struct {
1918
func (t *EnvironmentDetails) ToString(currentIndentation string) string {
2019
var location string
2120
if t.Location != "" {
22-
location = fmt.Sprintf("\nLocation: %s", color.BlueString(t.Location))
21+
location = fmt.Sprintf("\nLocation: %s", output.WithHighLightFormat(t.Location))
2322
}
2423
return fmt.Sprintf(
2524
"Subscription: %s%s\n",
26-
color.BlueString(t.Subscription),
25+
output.WithHighLightFormat(t.Subscription),
2726
location,
2827
)
2928
}

cli/azd/pkg/output/ux/show.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (s *ShowService) ToString(currentIndentation string) string {
2323
"%s\n"+
2424
" Endpoint: %s\n"+
2525
" Environment variables:\n"+
26-
color.HiBlueString(formatEnv(" ", s.Env)),
26+
output.WithHighLightFormat(formatEnv(" ", s.Env)),
2727
color.HiMagentaString("%s (Container App)", s.Name),
2828
output.WithLinkFormat(s.IngresUrl))
2929
}
@@ -71,7 +71,7 @@ func (s *Show) ToString(currentIndentation string) string {
7171
"%s%s%s%s%s%s%s%s%s %s\n",
7272
pickHeader,
7373
"To view a different environment, run ",
74-
color.HiBlueString("%s\n\n", "azd show -e <environment name>"),
74+
output.WithHighLightFormat("%s\n\n", "azd show -e <environment name>"),
7575
color.HiMagentaString(s.AppName),
7676
"\n Services:\n",
7777
services(s.Services),
@@ -86,8 +86,8 @@ func azurePortalLink(link string) string {
8686
if link == "" {
8787
return fmt.Sprintf(
8888
"Application is not yet provisioned. Run %s or %s first.",
89-
color.HiBlueString("azd provision"),
90-
color.HiBlueString("azd up"),
89+
output.WithHighLightFormat("azd provision"),
90+
output.WithHighLightFormat("azd up"),
9191
)
9292
}
9393
return output.WithLinkFormat(link)
@@ -98,14 +98,14 @@ func services(services []*ShowService) string {
9898
if servicesCount == 0 {
9999
return fmt.Sprintf(
100100
" You don't have services defined. Add your services to %s.",
101-
color.HiBlueString("azure.yaml"),
101+
output.WithHighLightFormat("azure.yaml"),
102102
)
103103
}
104104
lines := make([]string, servicesCount)
105105
for index, service := range services {
106106
lines[index] = fmt.Sprintf(
107107
" %s %s",
108-
color.HiBlueString(service.Name),
108+
output.WithHighLightFormat(service.Name),
109109
output.WithLinkFormat(service.IngresUrl),
110110
)
111111
}
@@ -117,7 +117,7 @@ func environments(environments []*ShowEnvironment) string {
117117
if environmentsCount == 0 {
118118
return fmt.Sprintf(
119119
" You haven't created any environments. Run %s to create one.",
120-
color.HiBlueString("azd env new"),
120+
output.WithHighLightFormat("azd env new"),
121121
)
122122
}
123123

@@ -133,7 +133,7 @@ func environments(environments []*ShowEnvironment) string {
133133
}
134134
lines[index] = fmt.Sprintf(
135135
" %s%s%s",
136-
color.HiBlueString(environment.Name),
136+
output.WithHighLightFormat(environment.Name),
137137
defaultEnv,
138138
output.WithGrayFormat(isRemote),
139139
)

0 commit comments

Comments
 (0)