vagrant/plugins/commands/box/command/remove.rb

37 lines
890 B
Ruby
Raw Normal View History

2012-04-19 20:59:48 +00:00
require 'optparse'
module VagrantPlugins
module CommandBox
module Command
2012-11-07 05:05:14 +00:00
class Remove < Vagrant.plugin("2", :command)
2012-04-19 20:59:48 +00:00
def execute
options = {}
opts = OptionParser.new do |opts|
2012-07-10 02:51:54 +00:00
opts.banner = "Usage: vagrant box remove <name> <provider>"
2012-04-19 20:59:48 +00:00
end
# Parse the options
argv = parse_options(opts)
return if !argv
2012-07-10 02:51:54 +00:00
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 2
2012-04-19 20:59:48 +00:00
b = nil
begin
b = @env.boxes.find(argv[0], argv[1].to_sym)
rescue Vagrant::Errors::BoxUpgradeRequired
@env.boxes.upgrade(argv[0])
retry
end
2012-04-19 20:59:48 +00:00
raise Vagrant::Errors::BoxNotFound, :name => argv[0] if !b
2012-07-10 02:51:54 +00:00
b.destroy!
2012-04-19 20:59:48 +00:00
# Success, exit status 0
0
end
end
end
end
end