diff --git a/plugins/providers/virtualbox/action.rb b/plugins/providers/virtualbox/action.rb index 65f929d26..722817cab 100644 --- a/plugins/providers/virtualbox/action.rb +++ b/plugins/providers/virtualbox/action.rb @@ -6,7 +6,9 @@ module VagrantPlugins autoload :CheckAccessible, File.expand_path("../action/check_accessible", __FILE__) autoload :CheckVirtualbox, File.expand_path("../action/check_virtualbox", __FILE__) autoload :Created, File.expand_path("../action/created", __FILE__) + autoload :DestroyConfirm, File.expand_path("../action/destroy_confirm", __FILE__) autoload :MessageNotCreated, File.expand_path("../action/message_not_created", __FILE__) + autoload :MessageWillNotDestroy, File.expand_path("../action/message_will_not_destroy", __FILE__) # Include the built-in modules so that we can use them as top-level # things. @@ -23,19 +25,12 @@ module VagrantPlugins next end - # If the VM is created, then we confirm that we want to - # destroy it. - message = I18n.t("vagrant.commands.destroy.confirmation", - :name => env[:machine].name) - confirm = Vagrant::Action::Builder.build(Confirm, message) - - b2.use Call, confirm do |env2, b3| + b2.use Call, DestroyConfirm do |env2, b3| if env2[:result] b3.use Vagrant::Action::General::Validate b3.use CheckAccessible else - env2[:ui].info I18n.t("vagrant.commands.destroy.will_not_destroy", - :name => env[:machine.name]) + b3.use MessageWillNotDestroy end end end diff --git a/plugins/providers/virtualbox/action/destroy_confirm.rb b/plugins/providers/virtualbox/action/destroy_confirm.rb new file mode 100644 index 000000000..797f9b737 --- /dev/null +++ b/plugins/providers/virtualbox/action/destroy_confirm.rb @@ -0,0 +1,16 @@ +require "vagrant/action/builtin/confirm" + +module VagrantPlugins + module ProviderVirtualBox + module Action + class DestroyConfirm < Vagrant::Action::Builtin::Confirm + def initialize(app, env) + message = I18n.t("vagrant.commands.destroy.confirmation", + :name => env[:machine].name) + + super(app, env, message) + end + end + end + end +end diff --git a/plugins/providers/virtualbox/action/message_will_not_destroy.rb b/plugins/providers/virtualbox/action/message_will_not_destroy.rb new file mode 100644 index 000000000..a80bea3c9 --- /dev/null +++ b/plugins/providers/virtualbox/action/message_will_not_destroy.rb @@ -0,0 +1,17 @@ +module VagrantPlugins + module ProviderVirtualBox + module Action + class MessageWillNotDestroy + def initialize(app, env) + @app = app + end + + def call(env) + env[:ui].info I18n.t("vagrant.commands.destroy.will_not_destroy", + :name => env[:machine].name) + @app.call(env) + end + end + end + end +end