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)
pull/10818/head
Anders F Björklund 2021-03-14 16:12:29 +01:00
parent ff0e25ada8
commit ce04eb53fd
3 changed files with 16 additions and 6 deletions

View File

@ -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...)

View File

@ -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},

View File

@ -51,6 +51,7 @@ const (
Happy
HealthCheck
Improvement
Indent
Internet
ISODownload
Issue