2018-07-07 10:41:15 +00:00
|
|
|
package clifmt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2018-07-08 23:34:21 +00:00
|
|
|
// Color returns a bash-formatted string representing
|
|
|
|
// the string @text with the color code @color and in bold
|
|
|
|
// if @bold (1 optional argument) is set to true
|
|
|
|
func Color(color byte, text string, bold ...bool) string {
|
2018-07-07 10:41:15 +00:00
|
|
|
b := "0"
|
|
|
|
if len(bold) > 0 && bold[0] {
|
|
|
|
b = "1"
|
|
|
|
}
|
2018-07-08 23:34:21 +00:00
|
|
|
return fmt.Sprintf("\033[%s;%dm%s\033[0m", b, color, text)
|
2018-07-07 10:41:15 +00:00
|
|
|
}
|