Pass terminal output color option from Ruby to terminal plugin

This commit is contained in:
sophia 2022-09-12 16:40:12 -04:00
parent 45d15e12c2
commit f7cd08b208
3 changed files with 6 additions and 13 deletions

View File

@ -195,8 +195,7 @@ func BaseCommand(ctx context.Context, log hclog.Logger, logOutput io.Writer, opt
}
}
if outputExperimentalWarning {
ui.Output(`
This is an experimental version of Vagrant. Please note that some things may
ui.Output(`This is an experimental version of Vagrant. Please note that some things may
not work as you expect and this version of Vagrant is not compatible with the
stable version of Vagrant. For more information about vagrant-go read the docs
at https://www.vagrantup.com/docs/experimental/vagrant_go. To disable this

View File

@ -17,12 +17,6 @@ module Vagrant
class Remote < Basic
attr_reader :client
COLOR_TO_STYLE = {
red: :error,
green: :success,
yellow: :warn
}
def initialize(client)
super()
@client = client
@ -41,13 +35,11 @@ module Vagrant
def safe_puts(message, **opts)
message, extra_opts = message
if !extra_opts[:color].nil?
extra_opts[:style] = COLOR_TO_STYLE[extra_opts[:color]]
end
opts = {
new_line: opts[:printer] == :puts,
style: extra_opts[:style],
bold: extra_opts[:bold]
bold: extra_opts[:bold],
color: extra_opts[:color]
}
client.output(message.gsub("%", "%%"), **opts)

View File

@ -33,7 +33,8 @@ module VagrantPlugins
input: SDK::TerminalUI::Event::Input.new(
prompt: prompt,
style: STYLE[:info],
secret: !opts[:echo]
secret: !opts[:echo],
color: opts[:color]
)
),
].each
@ -61,6 +62,7 @@ module VagrantPlugins
msg: line,
style: style,
disable_new_line: !opts[:new_line],
color: opts[:color]
)
)
].each