diff --git a/lib/vagrant/easy/command_base.rb b/lib/vagrant/easy/command_base.rb index 26d064aeb..4e5b4856e 100644 --- a/lib/vagrant/easy/command_base.rb +++ b/lib/vagrant/easy/command_base.rb @@ -5,26 +5,26 @@ module Vagrant # Base class for all easy commands. This contains the basic code # that knows how to run the easy commands. class CommandBase < Vagrant::Command::Base - @@command = nil - @@runner = nil + @command = nil + @runner = nil # This is called by the {EasyCommand.create} method when creating # an easy command to set the invocation command. def self.configure(name, &block) - @@command = name - @@runner = block + @command = name + @runner = block end def initialize(*args, &block) super - @logger = Log4r::Logger.new("vagrant::easy_command::#{@@command}") + @logger = Log4r::Logger.new("vagrant::easy_command::#{@command}") end def execute # Build up a basic little option parser opts = OptionParser.new do |opts| - opts.banner = "Usage: vagrant #{@@command}" + opts.banner = "Usage: vagrant #{@command}" end # Parse the options @@ -32,10 +32,10 @@ module Vagrant return if !argv # Run the action for each VM. - @logger.info("Running easy command: #{@@command}") + @logger.info("Running easy command: #{@command}") with_target_vms(argv) do |vm| @logger.debug("Running easy command for VM: #{vm.name}") - @@runner.call(Operations.new(vm)) + @runner.call(Operations.new(vm)) end # Exit status 0 every time for now diff --git a/test/unit/vagrant/plugin/v1_test.rb b/test/unit/vagrant/plugin/v1_test.rb index c187b3ab5..14cfacd9c 100644 --- a/test/unit/vagrant/plugin/v1_test.rb +++ b/test/unit/vagrant/plugin/v1_test.rb @@ -109,6 +109,16 @@ describe Vagrant::Plugin::V1 do # Check that the command class subclasses the easy command base plugin.command[:foo].should < Vagrant::Easy::CommandBase end + + it "should support registering multiple unique commands" do + plugins = %w(foo bar baz).map do |cmd| + [cmd, Vagrant::Easy.create_command(cmd)] + end + + plugins.each do |cmd, plugin| + plugin.instance_variable_get(:@command).should == cmd + end + end end describe "guests" do