fatih / color

Color package for Go (golang)
https://pkg.go.dev/github.com/fatih/color
MIT License
7.24k stars 615 forks source link

Feature Request #117

Closed iambenkay closed 3 years ago

iambenkay commented 3 years ago

Hello. Nice work on this package it almost totally served my use case. I seem to have noticed an important feature that I really need but is not included currently. I could write it myself and make a PR. Basically a flexible way of formatting text with different rich text parameters. Here is a sample and expected output:

   color.PrintRTf("The title is *%s*", "bold")
   color.PrintRTf("The title is _%s_", "italic")
   color.PrintRTf("The text color is $(fg:red|%s)", "red")
   color.PrintRTf("The background color is $(bg:green|%s)", "green")

Output: The title is bold The title is italic The text color is red ('red' should be colored red) The background color is green ('green' should have a green background)

So essentially, they can all be mixed in one format string and used.