UI class has a reference to the environment
This commit is contained in:
parent
e3b1f7ed1e
commit
64c3d46e1c
|
@ -45,7 +45,7 @@ module Vagrant
|
|||
# The last argument must _always_ be a Vagrant Environment class.
|
||||
raise CLIMissingEnvironment.new("This command requires that a Vagrant environment be properly passed in as the last parameter.") if !config[:env]
|
||||
@env = config[:env]
|
||||
@env.ui = UI::Shell.new(shell) if !@env.ui.is_a?(UI::Shell)
|
||||
@env.ui = UI::Shell.new(@env, shell) if !@env.ui.is_a?(UI::Shell)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ module Vagrant
|
|||
# The last argument must _always_ be a Vagrant Environment class.
|
||||
raise CLIMissingEnvironment.new("This command requires that a Vagrant environment be properly passed in as the last parameter.") if !config[:env]
|
||||
@env = config[:env]
|
||||
@env.ui = UI::Shell.new(shell) if !@env.ui.is_a?(UI::Shell)
|
||||
@env.ui = UI::Shell.new(@env, shell) if !@env.ui.is_a?(UI::Shell)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -138,7 +138,7 @@ module Vagrant
|
|||
# Returns the {UI} for the environment, which is responsible
|
||||
# for talking with the outside world.
|
||||
def ui
|
||||
@ui ||= UI.new
|
||||
@ui ||= UI.new(self)
|
||||
end
|
||||
|
||||
#---------------------------------------------------------------
|
||||
|
|
|
@ -3,6 +3,12 @@ module Vagrant
|
|||
# through a shell). They must respond to the typically logger methods
|
||||
# of `warn`, `error`, `info`, and `confirm`.
|
||||
class UI
|
||||
attr_reader :env
|
||||
|
||||
def initialize(env)
|
||||
@env = env
|
||||
end
|
||||
|
||||
[:warn, :error, :info, :confirm].each do |method|
|
||||
# By default these methods don't do anything. A silent UI.
|
||||
define_method(method) { |message| }
|
||||
|
@ -11,7 +17,9 @@ module Vagrant
|
|||
# A shell UI, which uses a `Thor::Shell` object to talk with
|
||||
# a terminal.
|
||||
class Shell < UI
|
||||
def initialize(shell)
|
||||
def initialize(env, shell)
|
||||
super(env)
|
||||
|
||||
@shell = shell
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue