<commit_before>require "log4r"

module Vagrant
  module Easy
    # 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

      # 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
      end

      def initialize(*args, &block)
        super

        @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}"
        end

        # Parse the options
        argv = parse_options(opts)
        return if !argv

        # Run the action for each VM.
        @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))
        end

        # Exit status 0 every time for now
        0
      end
    end
  end
end<commit_msg>Allow creating multiple easy commands<commit_after>require "log4r"

module Vagrant
  module Easy
    # Base class for all easy commands. This contains the basic code
    # that knows how to run the easy commands.
    class CommandBase < Vagrant::Command::Base
      # 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
      end

      def initialize(*args, &block)
        super

        @command = self.class.instance_variable_get(:@command)
        @runner  = self.class.instance_variable_get(:@runner)
        @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}"
        end

        # Parse the options
        argv = parse_options(opts)
        return if !argv

        # Run the action for each VM.
        @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))
        end

        # Exit status 0 every time for now
        0
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08967916505604948, 'fraction_numerical': 0.0030923850019327404, 'mean_word_length': 2.1754601226993864, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4490532', 'n_tokens_mistral': 733, 'n_tokens_neox': 719, 'n_words': 249}