Move UI to remote file and include options to client
This commit is contained in:
parent
df53588de5
commit
e090fa4e10
@ -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.
|
||||
|
||||
32
lib/vagrant/ui/remote.rb
Normal file
32
lib/vagrant/ui/remote.rb
Normal file
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user