2012-04-19 20:59:48 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module CommandDestroy
|
2012-06-26 23:18:02 +00:00
|
|
|
class Command < Vagrant.plugin("1", :command)
|
2010-08-25 06:05:40 +00:00
|
|
|
def execute
|
2012-02-08 06:58:01 +00:00
|
|
|
options = {}
|
|
|
|
|
2011-12-17 19:05:49 +00:00
|
|
|
opts = OptionParser.new do |opts|
|
|
|
|
opts.banner = "Usage: vagrant destroy [vm-name]"
|
2012-02-08 06:58:01 +00:00
|
|
|
opts.separator ""
|
|
|
|
|
|
|
|
opts.on("-f", "--force", "Destroy without confirmation.") do |f|
|
|
|
|
options[:force] = f
|
|
|
|
end
|
2011-12-17 19:05:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Parse the options
|
|
|
|
argv = parse_options(opts)
|
|
|
|
return if !argv
|
|
|
|
|
|
|
|
@logger.debug("'Destroy' each target VM...")
|
2012-03-11 22:32:17 +00:00
|
|
|
with_target_vms(argv, :reverse => true) do |vm|
|
2012-07-27 05:39:27 +00:00
|
|
|
vm.action(:destroy)
|
2010-08-25 06:05:40 +00:00
|
|
|
end
|
2012-03-23 15:07:35 +00:00
|
|
|
|
|
|
|
# Success, exit status 0
|
|
|
|
0
|
2012-07-28 02:29:40 +00:00
|
|
|
end
|
2010-08-25 06:05:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|