2012-04-19 20:59:48 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module CommandDestroy
|
2012-11-07 05:05:14 +00:00
|
|
|
class Command < Vagrant.plugin("2", :command)
|
2010-08-25 06:05:40 +00:00
|
|
|
def execute
|
2012-02-08 06:58:01 +00:00
|
|
|
options = {}
|
|
|
|
|
2012-08-14 06:18:50 +00:00
|
|
|
opts = OptionParser.new do |o|
|
|
|
|
o.banner = "Usage: vagrant destroy [vm-name]"
|
|
|
|
o.separator ""
|
2012-02-08 06:58:01 +00:00
|
|
|
|
2012-08-14 06:18:50 +00:00
|
|
|
o.on("-f", "--force", "Destroy without confirmation.") do |f|
|
2012-02-08 06:58:01 +00:00
|
|
|
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
|