From df0bbe343fdfccffb5059b4309f30be4c442a2bf Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 25 Feb 2022 15:58:08 -0800 Subject: [PATCH] Support bold style and add `#clear_line` --- plugins/commands/serve/client/terminal.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/commands/serve/client/terminal.rb b/plugins/commands/serve/client/terminal.rb index e097ee5a2..b209e7d63 100644 --- a/plugins/commands/serve/client/terminal.rb +++ b/plugins/commands/serve/client/terminal.rb @@ -6,7 +6,7 @@ module VagrantPlugins STYLE = { detail: "info", info: "info", - output: "output", + output: "info", warn: "warning", error: "error", success: "success", @@ -36,18 +36,33 @@ module VagrantPlugins # @param [Array] lines Lines to print def output(line, **opts) + style = STYLE[opts[:style]] + if opts[:bold] && style != "header" + style = "#{style}-bold" + end + client.events( [ SDK::TerminalUI::Event.new( line: SDK::TerminalUI::Event::Line.new( msg: line, - style: STYLE[opts[:style]], + style: style, disable_new_line: !opts[:new_line], ) ) ].each ).each {} end + + def clear_line + client.events( + [ + SDK::TerminalUI::Event.new( + clear_line: SDK::TerminalUI::Event::ClearLine.new + ) + ].each + ).each {} + end end end end