Merge pull request #260 from fkautz/pr_out_updating_how_colors_go_now_takes_variable_number_of_inputs

This commit is contained in:
Frederick F. Kautz IV
2015-04-08 13:37:25 -07:00
+20 -6
View File
@@ -22,23 +22,23 @@ import (
"github.com/fatih/color"
)
func fatal(msg interface{}) {
func fatal(msgs ...interface{}) {
red := color.New(color.FgRed)
boldRed := red.Add(color.Bold)
boldRed.Println(msg)
colorPrintln(boldRed, msgs)
os.Exit(1)
}
func warning(msg interface{}) {
func warning(msgs ...interface{}) {
yellow := color.New(color.FgYellow)
yellow.Println(msg)
colorPrintln(yellow, msgs)
}
func info(msg interface{}) {
func info(msgs ...interface{}) {
if !globalQuietFlag {
green := color.New(color.FgGreen)
boldGreen := green.Add(color.Bold)
boldGreen.Println(msg)
colorPrintln(boldGreen, msgs)
}
}
@@ -49,3 +49,17 @@ func infoCallback(msg string) {
boldGreen.Print("\r" + msg)
}
}
func colorPrint(c *color.Color, msgs []interface{}) {
for i, msg := range msgs {
if i != 0 {
c.Print(" ")
}
c.Print(msg)
}
}
func colorPrintln(c *color.Color, msgs []interface{}) {
colorPrint(c, msgs)
c.Println()
}