github.com/hugelgupf/u-root@v0.0.0-20191023214958-4807c632154c/pkg/checker/colours.go (about)

     1  // Copyright 2017-2019 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package checker
     6  
     7  import "fmt"
     8  
     9  // foreground colours
    10  const (
    11  	ColorBlack   = "\x1b[0;30m"
    12  	ColorRed     = "\x1b[0;31m"
    13  	ColorGreen   = "\x1b[0;32m"
    14  	ColorYellow  = "\x1b[0;33m"
    15  	ColorBlue    = "\x1b[0;34m"
    16  	ColorMagenta = "\x1b[0;35m"
    17  	ColorGrey    = "\x1b[0;36m"
    18  	ColorNone    = "\x1b[0m"
    19  )
    20  
    21  func colorize(col, f string, a ...interface{}) string {
    22  	return col + fmt.Sprintf(f, a...) + ColorNone
    23  }
    24  
    25  func red(format string, args ...interface{}) string {
    26  	return colorize(ColorRed, format, args...)
    27  }
    28  
    29  func green(format string, args ...interface{}) string {
    30  	return colorize(ColorGreen, format, args...)
    31  }
    32  
    33  func yellow(format string, args ...interface{}) string {
    34  	return colorize(ColorYellow, format, args...)
    35  }
    36  
    37  func blue(format string, args ...interface{}) string {
    38  	return colorize(ColorBlue, format, args...)
    39  }
    40  
    41  func magenta(format string, args ...interface{}) string {
    42  	return colorize(ColorMagenta, format, args...)
    43  }
    44  
    45  func grey(format string, args ...interface{}) string {
    46  	return colorize(ColorGrey, format, args...)
    47  }