diff --git a/bin/vagrant b/bin/vagrant index eaf78c669..ef6eaa814 100755 --- a/bin/vagrant +++ b/bin/vagrant @@ -2,10 +2,12 @@ require 'vagrant' require 'vagrant/cli' +env = Vagrant::Environment.load! + begin - Vagrant::CLI.start(ARGV, :env => Vagrant::Environment.load!) + Vagrant::CLI.start(ARGV, :env => env) rescue Vagrant::VagrantError => e - Vagrant.ui.error e.message - Vagrant.ui.error e.backtrace.join("\n") + env.ui.error e.message + env.ui.error e.backtrace.join("\n") exit e.status_code end diff --git a/lib/vagrant.rb b/lib/vagrant.rb index fca27effb..ba874012b 100644 --- a/lib/vagrant.rb +++ b/lib/vagrant.rb @@ -28,6 +28,7 @@ module Vagrant end class CLIMissingEnvironment < VagrantError; status_code(1); end + class BoxNotFound < VagrantError; status_code(2); end end # Load them up. One day we'll convert this to autoloads. Today diff --git a/lib/vagrant/command/box.rb b/lib/vagrant/command/box.rb index 5c80381af..6da7542cb 100644 --- a/lib/vagrant/command/box.rb +++ b/lib/vagrant/command/box.rb @@ -7,6 +7,25 @@ module Vagrant def add(name, uri) Box.add(env, name, uri) end + + desc "remove NAME", "Remove a box from the system" + def remove(name) + b = Box.find(env, name) + raise BoxNotFound.new("Box '#{name}' could not be found.") if !b + b.destroy + end + + desc "repackage NAME", "Repackage an installed box into a `.box` file." + def repackage(name) + b = Box.find(env, name) + raise BoxNotFound.new("Box '#{name}' could not be found.") if !b + b.repackage + end + + desc "list", "Lists all installed boxes" + def list + # TODO + end end end end