summaryrefslogtreecommitdiff
path: root/chef/lib/chef/knife
diff options
context:
space:
mode:
authorSahil Muthoo <sahil.muthoo@gmail.com>2012-08-09 01:37:14 +0530
committerBryan McLellan <btm@opscode.com>2012-09-07 15:33:48 -0700
commit5321f3fefa12c55a150e93468fe86f8f75eb05be (patch)
tree6b0db279a9f6be2d97ecd2ec234d3e0b589d65f3 /chef/lib/chef/knife
parentcc50e4b2834e4a996e922e4a23e621c9b568d283 (diff)
downloadchef-5321f3fefa12c55a150e93468fe86f8f75eb05be.tar.gz
Fix [CHEF-3355].
Fix knife status doesn't respect --no-color option or lack of a tty while colorizing output.
Diffstat (limited to 'chef/lib/chef/knife')
-rw-r--r--chef/lib/chef/knife/status.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/chef/lib/chef/knife/status.rb b/chef/lib/chef/knife/status.rb
index 5b098c9d0c..ceb394ce3a 100644
--- a/chef/lib/chef/knife/status.rb
+++ b/chef/lib/chef/knife/status.rb
@@ -55,7 +55,6 @@ class Chef
q.search(:node, query) do |node|
all_nodes << node
end
-
all_nodes.sort { |n1, n2|
if (config[:sort_reverse] || Chef::Config[:knife][:sort_status_reverse])
(n2["ohai_time"] or 0) <=> (n1["ohai_time"] or 0)
@@ -75,18 +74,18 @@ class Chef
minutes_text = "#{minutes} minute#{minutes == 1 ? ' ' : 's'}"
run_list = ", #{node.run_list}." if config[:run_list]
if hours > 24
- color = "RED"
+ color = :red
text = hours_text
elsif hours >= 1
- color = "YELLOW"
+ color = :yellow
text = hours_text
else
- color = "GREEN"
+ color = :green
text = minutes_text
end
line_parts = Array.new
- line_parts << "<%= color('#{text}', #{color}) %> ago" << node.name
+ line_parts << @ui.color(text, color) + " ago" << node.name
line_parts << fqdn if fqdn
line_parts << ipaddress if ipaddress
line_parts << run_list if run_list
@@ -98,7 +97,6 @@ class Chef
end
line_parts << platform
end
-
highline.say(line_parts.join(', ') + '.') unless (config[:hide_healthy] && hours < 1)
end