Permalink
Browse files

Defer loading for commands to last possible moment

  • Loading branch information...
mitchellh committed May 23, 2012
1 parent 22e54ee commit a1b37980e3480734c97306e8206ccc57b217c847
@@ -10,10 +10,25 @@ def initialize(argv, env)
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
@subcommands = Vagrant::Registry.new
- @subcommands.register(:add) { Add }
- @subcommands.register(:list) { List }
- @subcommands.register(:remove) { Remove }
- @subcommands.register(:repackage) { Repackage }
+ @subcommands.register(:add) do
+ require File.expand_path("../add", __FILE__)
+ Add
+ end
+
+ @subcommands.register(:list) do
+ require File.expand_path("../list", __FILE__)
+ List
+ end
+
+ @subcommands.register(:remove) do
+ require File.expand_path("../remove", __FILE__)
+ Remove
+ end
+
+ @subcommands.register(:repackage) do
+ require File.expand_path("../repackage", __FILE__)
+ Repackage
+ end
end
def execute
@@ -6,15 +6,10 @@ class Plugin < Vagrant.plugin("1")
name "box command"
description "The `box` command gives you a way to manage boxes."
- activated do
+ command("box") do
require File.expand_path("../command/root", __FILE__)
- require File.expand_path("../command/add", __FILE__)
- require File.expand_path("../command/list", __FILE__)
- require File.expand_path("../command/remove", __FILE__)
- require File.expand_path("../command/repackage", __FILE__)
+ Command::Root
end
-
- command("box") { Command::Root }
end
end
end
@@ -6,11 +6,10 @@ class Plugin < Vagrant.plugin("1")
name "destroy command"
description "The `destroy` command destroys your virtual machines."
- activated do
+ command("destroy") do
require File.expand_path("../command", __FILE__)
+ Command
end
-
- command("destroy") { Command }
end
end
end
@@ -9,11 +9,10 @@ class Plugin < Vagrant.plugin("1")
RubyGems into the Vagrant environment.
DESC
- activated do
+ command("gem") do
require File.expand_path("../command", __FILE__)
+ Command
end
-
- command("gem") { Command }
end
end
end
@@ -8,11 +8,10 @@ class Plugin < Vagrant.plugin("1")
The `halt` command halts your virtual machine.
DESC
- activated do
+ command("halt") do
require File.expand_path("../command", __FILE__)
+ Command
end
-
- command("halt") { Command }
end
end
end
@@ -9,11 +9,10 @@ class Plugin < Vagrant.plugin("1")
Vagrant-managed environment.
DESC
- activated do
+ command("init") do
require File.expand_path("../command", __FILE__)
+ Command
end
-
- command("init") { Command }
end
end
end
@@ -9,11 +9,10 @@ class Plugin < Vagrant.plugin("1")
environment and package it into a box file.
DESC
- activated do
+ command("package") do
require File.expand_path("../command", __FILE__)
+ Command
end
-
- command("package") { Command }
end
end
end
@@ -9,11 +9,10 @@ class Plugin < Vagrant.plugin("1")
configuration of the Vagrantfile.
DESC
- activated do
+ command("provision") do
require File.expand_path("../command", __FILE__)
+ Command
end
-
- command("provision") { Command }
end
end
end
@@ -1,5 +1,9 @@
require 'optparse'
+require "vagrant"
+
+require Vagrant.source_root.join("plugins/commands/up/start_mixins")
+
module VagrantPlugins
module CommandReload
class Command < Vagrant::Command::Base
@@ -9,11 +9,10 @@ class Plugin < Vagrant.plugin("1")
the Vagrantfile, and bring it back up.
DESC
- activated do
+ command("reload") do
require File.expand_path("../command", __FILE__)
+ Command
end
-
- command("reload") { Command }
end
end
end
@@ -8,11 +8,10 @@ class Plugin < Vagrant.plugin("1")
The `resume` command resumes a suspend virtual machine.
DESC
- activated do
+ command("resume") do
require File.expand_path("../command", __FILE__)
+ Command
end
-
- command("resume") { Command }
end
end
end
@@ -8,11 +8,10 @@ class Plugin < Vagrant.plugin("1")
The `ssh` command provides SSH access to the virtual machine.
DESC
- activated do
+ command("ssh") do
require File.expand_path("../command", __FILE__)
+ Command
end
-
- command("ssh") { Command }
end
end
end
@@ -9,11 +9,10 @@ class Plugin < Vagrant.plugin("1")
that can be used to quickly SSH into your virtual machine.
DESC
- activated do
+ command("ssh-config") do
require File.expand_path("../command", __FILE__)
+ Command
end
-
- command("ssh-config") { Command }
end
end
end
@@ -9,11 +9,10 @@ class Plugin < Vagrant.plugin("1")
in this environment.
DESC
- activated do
+ command("status") do
require File.expand_path("../command", __FILE__)
+ Command
end
-
- command("status") { Command }
end
end
end
@@ -8,11 +8,10 @@ class Plugin < Vagrant.plugin("1")
The `suspend` command suspends a running virtual machine.
DESC
- activated do
+ command("suspend") do
require File.expand_path("../command", __FILE__)
+ Command
end
-
- command("suspend") { Command }
end
end
end
@@ -1,5 +1,9 @@
require 'optparse'
+require "vagrant"
+
+require File.expand_path("../start_mixins", __FILE__)
+
module VagrantPlugins
module CommandUp
class Command < Vagrant::Command::Base
@@ -1,9 +1,5 @@
require "vagrant"
-# These are used by various other commands, so we just load them
-# up right away.
-require File.expand_path("../start_mixins", __FILE__)
-
module VagrantPlugins
module CommandUp
class Plugin < Vagrant.plugin("1")
@@ -12,11 +8,10 @@ class Plugin < Vagrant.plugin("1")
The `up` command brings the virtual environment up and running.
DESC
- activated do
+ command("up") do
require File.expand_path("../command", __FILE__)
+ Command
end
-
- command("up") { Command }
end
end
end

0 comments on commit a1b3798

Please sign in to comment.