-
-
Notifications
You must be signed in to change notification settings - Fork 214
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I'm just learning to use your library, so please excuse me if it is written somewhere, but I couldn't find anything.
First: thanks for providing this fine library and all the useful documentation (and demos!)!
Starting to use it, I got confused. I used this piece of code:
func p(a *pterm.AreaPrinter) {
foregroundRGB := pterm.RGB{R: 0, G: 0, B: 0}
backgroundRGB := pterm.RGB{R: 255, G: 0, B: 0}
aRGBStyle := pterm.NewRGBStyle(foregroundRGB, backgroundRGB)
aStyle := pterm.NewStyle(pterm.FgBlack,pterm.BgLightRed)
for i := 0; i < 5; i++ {
if i%2 == 0 {
a.Update(aStyle.Sprintf("Current count: %d\n",i))
} else {
a.Update(aRGBStyle.Sprintf("Current count: %d\n",i))
}
time.Sleep(time.Second)
}
}- the
astyle.Sprintfbehave like I would expect it to behave (and consistently withfmt.Sprintf): it outputs the string with the style applied. - the
aRGBStyle.Sprintfhowever, complains about a format mismatch:Current count: %!d(string=1)and even if you change the %d into a %s (which makes no sense?), only the value ofiis printed in the style. "Current count: " is still the default (white on black in my case). Only if you do aaRGBSyle.Sprintf("%s\n", "Current count: ", i)(with only the%sin the format, not%s%das one might expect) I got what I expected.
As said: maybe it's written somewhere, but I couldn't find the difference being mentioned in the documentation and at least IMHO it would be easier if these two Sprintf calls would behave consistently.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working