feat(display): make Faint respect Colorize

Make `display.Faint` respect the `Colorize` config value.
This commit is contained in:
Chris Lane
2020-11-27 22:50:55 -05:00
parent cdddfbb516
commit 1a7b5c6127
4 changed files with 29 additions and 6 deletions

View File

@@ -1,8 +1,18 @@
package display
import "fmt"
import (
"fmt"
"github.com/cheat/cheat/internal/config"
)
// Faint returns an faint string
func Faint(str string) string {
return fmt.Sprintf(fmt.Sprintf("\033[2m%s\033[0m", str))
func Faint(str string, conf config.Config) string {
// make `str` faint only if colorization has been requested
if conf.Colorize {
return fmt.Sprintf(fmt.Sprintf("\033[2m%s\033[0m", str))
}
// otherwise, return the string unmodified
return str
}