Provisioner output is now colorized based on stdout/stderr [GH-595]
This commit is contained in:
parent
f37778c848
commit
5f567f30d8
|
@ -13,6 +13,8 @@
|
|||
- Error message for improperly packaged box files. [GH-198]
|
||||
- Copy insecure private key to user-owned directory so even
|
||||
`sudo` installed Vagrant installations work. [GH-580]
|
||||
- Provisioner stdout/stderr is now color coded based on stdout/stderr.
|
||||
stdout is green, stderr is red. [GH-595]
|
||||
|
||||
## 0.8.10 (December 10, 2011)
|
||||
|
||||
|
|
|
@ -102,7 +102,12 @@ module Vagrant
|
|||
if type == :exit_status
|
||||
ssh.check_exit_status(data, command)
|
||||
else
|
||||
env[:ui].info("#{data}: #{type}")
|
||||
# Output the data with the proper color based on the stream.
|
||||
color = type == :stdout ? :green : :red
|
||||
|
||||
# Note: Be sure to chomp the data to avoid the newlines that the
|
||||
# Chef outputs.
|
||||
env[:ui].info(data.chomp, :color => color, :prefix => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -133,7 +133,12 @@ module Vagrant
|
|||
if type == :exit_status
|
||||
ssh.check_exit_status(data, command)
|
||||
else
|
||||
env[:ui].info("#{data}: #{type}")
|
||||
# Output the data with the proper color based on the stream.
|
||||
color = type == :stdout ? :green : :red
|
||||
|
||||
# Note: Be sure to chomp the data to avoid the newlines that the
|
||||
# Chef outputs.
|
||||
env[:ui].info(data.chomp, :color => color, :prefix => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -129,7 +129,12 @@ module Vagrant
|
|||
if type == :exit_status
|
||||
ssh.check_exit_status(data, commands)
|
||||
else
|
||||
env.ui.info(data)
|
||||
# Output the data with the proper color based on the stream.
|
||||
color = type == :stdout ? :green : :red
|
||||
|
||||
# Note: Be sure to chomp the data to avoid the newlines that the
|
||||
# Chef outputs.
|
||||
env[:ui].info(data.chomp, :color => color, :prefix => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -87,7 +87,12 @@ module Vagrant
|
|||
if type == :exit_status
|
||||
ssh.check_exit_status(data, commands)
|
||||
else
|
||||
env[:ui].info(data)
|
||||
# Output the data with the proper color based on the stream.
|
||||
color = type == :stdout ? :green : :red
|
||||
|
||||
# Note: Be sure to chomp the data to avoid the newlines that the
|
||||
# Chef outputs.
|
||||
env[:ui].info(data.chomp, :color => color, :prefix => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -99,16 +99,18 @@ module Vagrant
|
|||
# but is up to the user of the class to verify this is the case.
|
||||
class Colored < Basic
|
||||
# Terminal colors
|
||||
CLEAR = "\e[0m"
|
||||
YELLOW = "\e[33m"
|
||||
RED = "\e[31m"
|
||||
GREEN = "\e[32m"
|
||||
COLORS = {
|
||||
:clear => "\e[0m",
|
||||
:red => "\e[31m",
|
||||
:green => "\e[32m",
|
||||
:yellow => "\e[33m"
|
||||
}
|
||||
|
||||
# Mapping between type of message and the color to output
|
||||
COLOR_MAP = {
|
||||
:warn => YELLOW,
|
||||
:error => RED,
|
||||
:success => GREEN
|
||||
:warn => COLORS[:yellow],
|
||||
:error => COLORS[:red],
|
||||
:success => COLORS[:green]
|
||||
}
|
||||
|
||||
# This is called by `say` to format the message for output.
|
||||
|
@ -116,8 +118,15 @@ module Vagrant
|
|||
# Get the format of the message before adding color.
|
||||
message = super
|
||||
|
||||
# Colorize the message if there is a color for this type of message
|
||||
message = "#{COLOR_MAP[type]}#{message}#{CLEAR}" if COLOR_MAP[type]
|
||||
# Colorize the message if there is a color for this type of message,
|
||||
# either specified by the options or via the default color map.
|
||||
if opts.has_key?(:color)
|
||||
color = COLORS[opts[:color]]
|
||||
message = "#{color}#{message}#{COLORS[:clear]}"
|
||||
else
|
||||
message = "#{COLOR_MAP[type]}#{message}#{COLORS[:clear]}" if COLOR_MAP[type]
|
||||
end
|
||||
|
||||
message
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue