From f7cd08b208abf8e0cd9ea45fd65f2ae11be3ea02 Mon Sep 17 00:00:00 2001 From: sophia Date: Mon, 12 Sep 2022 16:40:12 -0400 Subject: [PATCH] Pass terminal output color option from Ruby to terminal plugin --- internal/cli/base.go | 3 +-- lib/vagrant/ui/remote.rb | 12 ++---------- plugins/commands/serve/client/terminal.rb | 4 +++- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/internal/cli/base.go b/internal/cli/base.go index 1bf512731..f64da4d05 100644 --- a/internal/cli/base.go +++ b/internal/cli/base.go @@ -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 diff --git a/lib/vagrant/ui/remote.rb b/lib/vagrant/ui/remote.rb index 445e5045e..da6e6fcef 100644 --- a/lib/vagrant/ui/remote.rb +++ b/lib/vagrant/ui/remote.rb @@ -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) diff --git a/plugins/commands/serve/client/terminal.rb b/plugins/commands/serve/client/terminal.rb index 0449f1cec..ea4776fe7 100644 --- a/plugins/commands/serve/client/terminal.rb +++ b/plugins/commands/serve/client/terminal.rb @@ -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