diff --git a/lib/vagrant/command/base.rb b/lib/vagrant/command/base.rb index c01e5c7c4..150b6ec67 100644 --- a/lib/vagrant/command/base.rb +++ b/lib/vagrant/command/base.rb @@ -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 diff --git a/lib/vagrant/command/group_base.rb b/lib/vagrant/command/group_base.rb index cfaafc10f..cf31f3386 100644 --- a/lib/vagrant/command/group_base.rb +++ b/lib/vagrant/command/group_base.rb @@ -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 diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 44711889a..fb8c1c11f 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -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 #--------------------------------------------------------------- diff --git a/lib/vagrant/ui.rb b/lib/vagrant/ui.rb index 8dea23d69..52c56b1cc 100644 --- a/lib/vagrant/ui.rb +++ b/lib/vagrant/ui.rb @@ -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