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]
|
- Error message for improperly packaged box files. [GH-198]
|
||||||
- Copy insecure private key to user-owned directory so even
|
- Copy insecure private key to user-owned directory so even
|
||||||
`sudo` installed Vagrant installations work. [GH-580]
|
`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)
|
## 0.8.10 (December 10, 2011)
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,12 @@ module Vagrant
|
||||||
if type == :exit_status
|
if type == :exit_status
|
||||||
ssh.check_exit_status(data, command)
|
ssh.check_exit_status(data, command)
|
||||||
else
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -133,7 +133,12 @@ module Vagrant
|
||||||
if type == :exit_status
|
if type == :exit_status
|
||||||
ssh.check_exit_status(data, command)
|
ssh.check_exit_status(data, command)
|
||||||
else
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -129,7 +129,12 @@ module Vagrant
|
||||||
if type == :exit_status
|
if type == :exit_status
|
||||||
ssh.check_exit_status(data, commands)
|
ssh.check_exit_status(data, commands)
|
||||||
else
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -87,7 +87,12 @@ module Vagrant
|
||||||
if type == :exit_status
|
if type == :exit_status
|
||||||
ssh.check_exit_status(data, commands)
|
ssh.check_exit_status(data, commands)
|
||||||
else
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -99,16 +99,18 @@ module Vagrant
|
||||||
# but is up to the user of the class to verify this is the case.
|
# but is up to the user of the class to verify this is the case.
|
||||||
class Colored < Basic
|
class Colored < Basic
|
||||||
# Terminal colors
|
# Terminal colors
|
||||||
CLEAR = "\e[0m"
|
COLORS = {
|
||||||
YELLOW = "\e[33m"
|
:clear => "\e[0m",
|
||||||
RED = "\e[31m"
|
:red => "\e[31m",
|
||||||
GREEN = "\e[32m"
|
:green => "\e[32m",
|
||||||
|
:yellow => "\e[33m"
|
||||||
|
}
|
||||||
|
|
||||||
# Mapping between type of message and the color to output
|
# Mapping between type of message and the color to output
|
||||||
COLOR_MAP = {
|
COLOR_MAP = {
|
||||||
:warn => YELLOW,
|
:warn => COLORS[:yellow],
|
||||||
:error => RED,
|
:error => COLORS[:red],
|
||||||
:success => GREEN
|
:success => COLORS[:green]
|
||||||
}
|
}
|
||||||
|
|
||||||
# This is called by `say` to format the message for output.
|
# 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.
|
# Get the format of the message before adding color.
|
||||||
message = super
|
message = super
|
||||||
|
|
||||||
# Colorize the message if there is a color for this type of message
|
# Colorize the message if there is a color for this type of message,
|
||||||
message = "#{COLOR_MAP[type]}#{message}#{CLEAR}" if COLOR_MAP[type]
|
# 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
|
message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue