Sha256: ceee70c395ae1d904db58ffa965a2700d0629d93035eeb18015ab63652e5e56d

Contents?: true

Size: 1001 Bytes

Versions: 6

Compression:

Stored size: 1001 Bytes

Contents

module VagrantPlugins
  module CommandDestroy
    class Command < Vagrant.plugin("2", :command)
      def execute
        options = {}
        options[:force] = false

        opts = OptionParser.new do |o|
          o.banner = "Usage: vagrant destroy [vm-name]"
          o.separator ""

          o.on("-f", "--force", "Destroy without confirmation.") do |f|
            options[:force] = f
          end
        end

        # Parse the options
        argv = parse_options(opts)
        return if !argv

        @logger.debug("'Destroy' each target VM...")
        declined = false
        with_target_vms(argv, :reverse => true) do |vm|
          action_env = vm.action(
            :destroy, :force_confirm_destroy => options[:force])

          declined = true if action_env.has_key?(:force_confirm_destroy_result) &&
            action_env[:force_confirm_destroy_result] == false
        end

        # Success if no confirms were declined
        declined ? 1 : 0
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
tamtam-vagrant-reload-1.1.3 vendor/cache/vagrant-0ac2a8738841/plugins/commands/destroy/command.rb
tamtam-vagrant-reload-1.1.2 vendor/cache/vagrant-0ac2a8738841/plugins/commands/destroy/command.rb
tamtam-vagrant-reload-1.1.1 vendor/cache/vagrant-0ac2a8738841/plugins/commands/destroy/command.rb
tamtam-vagrant-reload-1.1 vendor/cache/vagrant-0ac2a8738841/plugins/commands/destroy/command.rb
tnargav-1.3.6 plugins/commands/destroy/command.rb
tnargav-1.3.3 plugins/commands/destroy/command.rb