Defer loading for commands to last possible moment
This commit is contained in:
parent
22e54eed58
commit
a1b37980e3
|
@ -10,10 +10,25 @@ module VagrantPlugins
|
|||
@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 @@ module VagrantPlugins
|
|||
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 @@ module VagrantPlugins
|
|||
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 @@ module VagrantPlugins
|
|||
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 @@ module VagrantPlugins
|
|||
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 @@ module VagrantPlugins
|
|||
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 @@ module VagrantPlugins
|
|||
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 @@ module VagrantPlugins
|
|||
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 @@ module VagrantPlugins
|
|||
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 @@ module VagrantPlugins
|
|||
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 @@ module VagrantPlugins
|
|||
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 @@ module VagrantPlugins
|
|||
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 @@ module VagrantPlugins
|
|||
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 @@ module VagrantPlugins
|
|||
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 @@ module VagrantPlugins
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue