check NO_COLOR
envval
Support `NO_COLOR` (https://no-color.org/) to make parsing output easy.
This commit is contained in:
parent
9f2378959e
commit
c182d46d24
Notes:
git
2022-12-26 14:06:53 +00:00
@ -33,9 +33,11 @@ class Colorize
|
||||
"bold"=>"1", "underline"=>"4", "reverse"=>"7",
|
||||
}
|
||||
|
||||
NO_COLOR = (nc = ENV['NO_COLOR']) && !nc.empty?
|
||||
|
||||
# colorize.decorate(str, name = color_name)
|
||||
def decorate(str, name = @color)
|
||||
if @colors and color = (@colors[name] || DEFAULTS[name])
|
||||
if !NO_COLOR and @colors and color = (@colors[name] || DEFAULTS[name])
|
||||
"#{@beg}#{color}m#{str}#{@reset}"
|
||||
else
|
||||
str
|
||||
|
Loading…
x
Reference in New Issue
Block a user