From 23dfc45df2d3435a0c9dc7998995de7e21d9a356 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 10 Jul 2012 22:27:37 -0700 Subject: [PATCH] `box repackage` now uses new Box API --- plugins/commands/box/command/repackage.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/plugins/commands/box/command/repackage.rb b/plugins/commands/box/command/repackage.rb index 396df577b..edcaa1571 100644 --- a/plugins/commands/box/command/repackage.rb +++ b/plugins/commands/box/command/repackage.rb @@ -1,3 +1,4 @@ +require "fileutils" require 'optparse' module VagrantPlugins @@ -8,17 +9,24 @@ module VagrantPlugins options = {} opts = OptionParser.new do |opts| - opts.banner = "Usage: vagrant box repackage " + opts.banner = "Usage: vagrant box repackage " end # Parse the options argv = parse_options(opts) 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]) - raise Vagrant::Errors::BoxNotFound, :name => argv[0] if !b - b.repackage + box_name = argv[0] + box_provider = argv[1].to_sym + + # 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 0