From ce04eb53fd4d712fc404ebc057d013b49293b878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Sun, 14 Mar 2021 16:12:29 +0100 Subject: [PATCH] Add the possibility to output indented strings Sometimes you want to process the style string and output it with indentation but without any extra emojis. So add special variants. Also make the enum names more sane for LowIndent, LowIndentBullet (which removes the need of commenting why the enum name was wrong) --- pkg/minikube/out/out.go | 6 ++++++ pkg/minikube/style/style.go | 15 +++++++++------ pkg/minikube/style/style_enum.go | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pkg/minikube/out/out.go b/pkg/minikube/out/out.go index bdc069ad96..09919280e3 100644 --- a/pkg/minikube/out/out.go +++ b/pkg/minikube/out/out.go @@ -109,6 +109,12 @@ func Styled(st style.Enum, format string, a ...V) { } } +// Sprintf is used for returning the string (doesn't write anything) +func Sprintf(st style.Enum, format string, a ...V) string { + outStyled, _ := stylized(st, useColor, format, a...) + return outStyled +} + // Infof is used for informational logs (options, env variables, etc) func Infof(format string, a ...V) { outStyled, _ := stylized(style.Option, useColor, format, a...) diff --git a/pkg/minikube/style/style.go b/pkg/minikube/style/style.go index f7883fca96..907ff96428 100644 --- a/pkg/minikube/style/style.go +++ b/pkg/minikube/style/style.go @@ -23,8 +23,10 @@ import ( var ( // LowBullet is a bullet-point prefix for Low-fi mode LowBullet = "* " - // LowIndent is an indented bullet-point prefix for Low-fi mode - LowIndent = " - " + // LowIndent is an indented prefix for Low-fi mode + LowIndent = " " + // LowIndentBullet is an indented bullet-point prefix for Low-fi mode + LowIndentBullet = " - " // LowWarning is a warning prefix for Low-fi mode LowWarning = "! " // LowError is an error prefix for Low-fi mode @@ -53,19 +55,20 @@ const SpinnerCharacter = 9 var Config = map[Enum]Options{ Celebration: {Prefix: "πŸŽ‰ "}, Check: {Prefix: "βœ… "}, - Command: {Prefix: " β–ͺ ", LowPrefix: LowIndent}, // Indented bullet + Command: {Prefix: " β–ͺ ", LowPrefix: LowIndentBullet}, Confused: {Prefix: "πŸ˜• "}, Deleted: {Prefix: "πŸ’€ "}, Documentation: {Prefix: "πŸ“˜ "}, Empty: {Prefix: "", LowPrefix: ""}, Happy: {Prefix: "πŸ˜„ "}, - Issue: {Prefix: " β–ͺ ", LowPrefix: LowIndent}, // Indented bullet + Issue: {Prefix: " β–ͺ ", LowPrefix: LowIndentBullet}, + Indent: {Prefix: " ", LowPrefix: LowIndent}, Issues: {Prefix: "🍿 "}, Launch: {Prefix: "πŸš€ "}, LogEntry: {Prefix: " "}, // Indent New: {Prefix: "πŸ†• "}, Notice: {Prefix: "πŸ“Œ "}, - Option: {Prefix: " β–ͺ ", LowPrefix: LowIndent}, // Indented bullet + Option: {Prefix: " β–ͺ ", LowPrefix: LowIndentBullet}, Pause: {Prefix: "⏸️ "}, Provisioning: {Prefix: "🌱 "}, Ready: {Prefix: "πŸ„ "}, @@ -129,7 +132,7 @@ var Config = map[Enum]Options{ StartingNone: {Prefix: "🀹 "}, StartingSSH: {Prefix: "πŸ”— "}, StartingVM: {Prefix: "πŸ”₯ ", OmitNewline: true, Spinner: true}, - SubStep: {Prefix: " β–ͺ ", LowPrefix: LowIndent, OmitNewline: true, Spinner: true}, // Indented bullet + SubStep: {Prefix: " β–ͺ ", LowPrefix: LowIndentBullet, OmitNewline: true, Spinner: true}, Tip: {Prefix: "πŸ’‘ "}, Unmount: {Prefix: "πŸ”₯ "}, VerifyingNoLine: {Prefix: "πŸ€” ", OmitNewline: true}, diff --git a/pkg/minikube/style/style_enum.go b/pkg/minikube/style/style_enum.go index 7647fba2ea..10b12d8598 100644 --- a/pkg/minikube/style/style_enum.go +++ b/pkg/minikube/style/style_enum.go @@ -51,6 +51,7 @@ const ( Happy HealthCheck Improvement + Indent Internet ISODownload Issue