github.com/roscopecoltran/glide@v0.12.3/msg/out.go (about)

     1  // +build !windows
     2  
     3  package msg
     4  
     5  import "fmt"
     6  
     7  // These contanstants map to color codes for shell scripts making them
     8  // human readable.
     9  const (
    10  	Blue   = "0;34"
    11  	Red    = "0;31"
    12  	Green  = "0;32"
    13  	Yellow = "0;33"
    14  	Cyan   = "0;36"
    15  	Pink   = "1;35"
    16  )
    17  
    18  // Color returns a string in a certain color. The first argument is a string
    19  // containing the color code or a constant from the table above mapped to a code.
    20  //
    21  // The following will print the string "Foo" in yellow:
    22  //     fmt.Print(Color(Yellow, "Foo"))
    23  func (m *Messenger) Color(code, msg string) string {
    24  	if m.NoColor {
    25  		return msg
    26  	}
    27  	return fmt.Sprintf("\033[%sm%s\033[m", code, msg)
    28  }