`box repackage` now uses new Box API

This commit is contained in:
Mitchell Hashimoto 2012-07-10 22:27:37 -07:00
parent cc076e5ee5
commit 23dfc45df2
1 changed files with 13 additions and 5 deletions

View File

@ -1,3 +1,4 @@
require "fileutils"
require 'optparse' require 'optparse'
module VagrantPlugins module VagrantPlugins
@ -8,17 +9,24 @@ module VagrantPlugins
options = {} options = {}
opts = OptionParser.new do |opts| opts = OptionParser.new do |opts|
opts.banner = "Usage: vagrant box repackage <name>" opts.banner = "Usage: vagrant box repackage <name> <provider>"
end end
# Parse the options # Parse the options
argv = parse_options(opts) argv = parse_options(opts)
return if !argv return if !argv
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 1 raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 2
b = @env.boxes.find(argv[0]) box_name = argv[0]
raise Vagrant::Errors::BoxNotFound, :name => argv[0] if !b box_provider = argv[1].to_sym
b.repackage
# Verify the box exists that we want to repackage
box = @env.boxes.find(box_name, box_provider)
raise Vagrant::Errors::BoxNotFound, :name => box_name if !b
# Repackage the box
output_path = File.expand_path(@env.config.global.package.name, FileUtils.pwd)
box.repackage(output_path)
# Success, exit status 0 # Success, exit status 0
0 0