summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilan Stastny <milan@stastnej.ch>2021-01-29 10:37:50 +0100
committerMilan Stastny <milan@stastnej.ch>2021-01-29 10:37:50 +0100
commiteb4341ffe0b414bec79aac0a21734975c4eafcb5 (patch)
treedc80c18572b34d3815c868b080c14aedbcdcb85d
parent56e34ada7002f4956af6a0136e975f8972328567 (diff)
downloadchef-eb4341ffe0b414bec79aac0a21734975c4eafcb5.tar.gz
Replace hardcoded colours with pastel
Signed-off-by: Milan Stastny <mistastn@cisco.com>
-rw-r--r--lib/chef/compliance/reporter/cli.rb22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/chef/compliance/reporter/cli.rb b/lib/chef/compliance/reporter/cli.rb
index 5f1f9be01f..1d88f02eb5 100644
--- a/lib/chef/compliance/reporter/cli.rb
+++ b/lib/chef/compliance/reporter/cli.rb
@@ -24,39 +24,45 @@ class Chef
private
+ # pastel.decorate is a lightweight replacement for highline.color
+ def pastel
+ @pastel ||= begin
+ require "pastel" unless defined?(Pastel)
+ Pastel.new
+ end
+ end
+
def format_result(result)
output = []
found = false
if result[:status] == "failed"
if result[:code_desc]
found = true
- output << " \033[31m\xE2\x9D\x8C #{result[:code_desc]}\033[0m"
+ output << pastel.red(" #{result[:code_desc]}")
end
if result[:message]
if found
result[:message].split(/\n/).reject(&:empty?).each do |m|
- output << " \033[31m#{m}\033[0m"
+ output << pastel.red(" #{m}")
end
else
- prefix = "\xE2\x9D\x8C"
result[:message].split(/\n/).reject(&:empty?).each do |m|
- output << " \033[31m#{prefix}#{m}\033[0m"
- prefix = ""
+ output << pastel.red(" #{prefix}#{m}")
end
end
found = true
end
unless found
- output << " \033[31m\xE2\x9D\x8C #{result[:status]}\033[0m"
+ output << pastel.red(" #{result[:status]}")
end
else
found = false
if result[:code_desc]
found = true
- output << " \033[32m\xE2\x9C\x94 #{result[:code_desc]}\033[0m"
+ output << pastel.green(" #{result[:code_desc]}")
end
unless found
- output << " \033[32m\xE2\x9C\x94 #{result[:status]}\033[0m"
+ output << pastel.green(" #{result[:status]}")
end
end
output