diff --git a/lib/vagrant/ui.rb b/lib/vagrant/ui.rb index 8c3f95131..16bb28890 100644 --- a/lib/vagrant/ui.rb +++ b/lib/vagrant/ui.rb @@ -9,6 +9,7 @@ require "vagrant/util/safe_puts" module Vagrant module UI + autoload :Remote, "vagrant/ui/remote" # Vagrant UIs handle communication with the outside world (typically # through a shell). They must respond to the following methods: # @@ -283,31 +284,6 @@ module Vagrant end end - class RemoteUI < Basic - def initialize(client) - super() - @client = client - end - - def clear_line - # no-op - end - - # This method handles actually outputting a message of a given type - # to the console. - def say(type, message, opts={}) - @client.output([message.gsub("%", "%%")]) - end - - [:detail, :info, :warn, :error, :output, :success].each do |method| - class_eval <<-CODE - def #{method}(message, *args) - say(#{method.inspect}, message, *args) - end - CODE - end - end - # Prefixed wraps an existing UI and adds a prefix to it. class Prefixed < Interface # The prefix for `output` messages. diff --git a/lib/vagrant/ui/remote.rb b/lib/vagrant/ui/remote.rb new file mode 100644 index 000000000..0be2a0254 --- /dev/null +++ b/lib/vagrant/ui/remote.rb @@ -0,0 +1,32 @@ +module Vagrant + module UI + class RemoteUI < Basic + def initialize(client) + super() + @client = client + end + + def clear_line + # no-op + end + + # This method handles actually outputting a message of a given type + # to the console. + def say(type, message, opts={}) + if !opts.key?(:new_line) + opts[:new_line] = true + end + opts[:style] = type.to_sym + @client.output([message.gsub("%", "%%")], **opts) + end + + [:detail, :info, :warn, :error, :output, :success].each do |method| + class_eval <<-CODE + def #{method}(message, *args) + say(#{method.inspect}, message, *args) + end + CODE + end + end + end +end