summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-03-02 17:55:23 -0800
committerGitHub <noreply@github.com>2020-03-02 17:55:23 -0800
commit173b413690d93e7bfb439b0a586b9563384e3072 (patch)
tree660e3dcb2fa2c0a115dc386f53549be848cd5ac4 /lib/chef
parent5139c1a3fbf3535d763c31b3071022dc3a4ab3d5 (diff)
parentc0368ea911daff28e0759c91e08c53a2e986fa45 (diff)
downloadchef-173b413690d93e7bfb439b0a586b9563384e3072.tar.gz
Merge pull request #9434 from chef/btm/colors
Replace highline.color with pastel.decorate
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/formatters/indentable_output_stream.rb23
-rw-r--r--lib/chef/knife/core/ui.rb10
2 files changed, 16 insertions, 17 deletions
diff --git a/lib/chef/formatters/indentable_output_stream.rb b/lib/chef/formatters/indentable_output_stream.rb
index 5d58df6f11..d508a32eb0 100644
--- a/lib/chef/formatters/indentable_output_stream.rb
+++ b/lib/chef/formatters/indentable_output_stream.rb
@@ -17,23 +17,14 @@ class Chef
@semaphore = Mutex.new
end
- def highline
- @highline ||= begin
- require "highline"
- HighLine.new
+ # pastel.decorate is a lightweight replacement for highline.color
+ def pastel
+ @pastel ||= begin
+ require "pastel"
+ Pastel.new
end
end
- # Print text. This will start a new line and indent if necessary
- # but will not terminate the line (future print and puts statements
- # will start off where this print left off).
- #
- # @param string [String]
- # @param args [Array<Hash,Symbol>]
- def color(string, *args)
- print(string, from_args(args))
- end
-
# Print the start of a new line. This will terminate any existing lines and
# cause indentation but will not move to the next line yet (future 'print'
# and 'puts' statements will stay on this line).
@@ -83,7 +74,7 @@ class Chef
#
# == Alternative
#
- # You may also call print('string', :red) (a list of colors a la Highline.color)
+ # You may also call print('string', :red) (https://github.com/piotrmurach/pastel#3-supported-colors)
def print(string, *args)
options = from_args(args)
@@ -140,7 +131,7 @@ class Chef
end
if Chef::Config[:color] && options[:colors]
- @out.print highline.color(line, *options[:colors])
+ @out.print pastel.decorate(line, *options[:colors])
else
@out.print line
end
diff --git a/lib/chef/knife/core/ui.rb b/lib/chef/knife/core/ui.rb
index 41fb37c220..0dfa1db79c 100644
--- a/lib/chef/knife/core/ui.rb
+++ b/lib/chef/knife/core/ui.rb
@@ -61,6 +61,14 @@ class Chef
end
end
+ # pastel.decorate is a lightweight replacement for highline.color
+ def pastel
+ @pastel ||= begin
+ require "pastel"
+ Pastel.new
+ end
+ end
+
# Prints a message to stdout. Aliased as +info+ for compatibility with
# the logger API.
#
@@ -134,7 +142,7 @@ class Chef
def color(string, *colors)
if color?
- highline.color(string, *colors)
+ pastel.decorate(string, *colors)
else
string
end