diff --git a/CHANGELOG.md b/CHANGELOG.md index 654ad6dc2..557d9a309 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ a Vagrant environment is loaded. I don't anticipate this causing any problems but it is a backwards incompatible change should a plugin depend on this (but I don't see any reason why they would). + - `vagrant destroy` now asks for confirmation by default. This can be + overridden with the `--force` flag. [GH-699] ## 0.9.6 (February 7, 2012) diff --git a/lib/vagrant/command/destroy.rb b/lib/vagrant/command/destroy.rb index 0a9e6dc59..058a0a3db 100644 --- a/lib/vagrant/command/destroy.rb +++ b/lib/vagrant/command/destroy.rb @@ -15,8 +15,17 @@ module Vagrant @logger.debug("'Destroy' each target VM...") with_target_vms(argv[0]) do |vm| if vm.created? - @logger.info("Destroying: #{vm.name}") - vm.destroy + choice = @env.ui.ask(I18n.t("vagrant.commands.destroy.confirmation", + :name => vm.name)) + + if choice.upcase == "Y" + @logger.info("Destroying: #{vm.name}") + vm.destroy + else + @logger.info("Not destroying #{vm.name} since confirmation was declined.") + @env.ui.success(I18n.t("vagrant.commands.destroy.will_not_destroy", + :name => vm.name), :prefix => false) + end else @logger.info("Not destroying #{vm.name}, since it isn't created.") vm.ui.info I18n.t("vagrant.commands.common.vm_not_created") diff --git a/templates/locales/en.yml b/templates/locales/en.yml index d870cfd76..b85da67ad 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -231,6 +231,11 @@ en: vm_not_running: "VM is not currently running. Please bring it up to run this command." box: no_installed_boxes: "There are no installed boxes! Use `vagrant box add` to add some." + destroy: + confirmation: "Are you sure you want to destroy the '%{name}' VM? [Y/N] " + will_not_destroy: |- + The VM '%{name}' will not be destroyed, since the confirmation + was declined. gem: help_preamble: |- `vagrant gem` is used to install Vagrant plugins via the RubyGems