<commit_before>require 'cabar/base'

require 'cabar/context'
require 'cabar/plugin'
require 'cabar/command/manager'
require 'cabar/command/runner'


module Cabar

  # Main bin/cbr script object.
  class Main < Base
    # Raw command line arguments from bin/cbr.
    attr_accessor :args

    # The Cabar::Command::Manager for top-level commands.
    attr_accessor :commands

    # The Cabar::Plugin::Manager.
    attr_accessor :plugin_manager

    def self.current
      @@current || raise(Error, "Cabar::Main not initialized")
    end

    def initialize *args
      @commands = Command::Manager.factory.
        new(:main => self, 
            :owner => self)

      super
      @@current = self

      import_standard_plugins!
    end

    def plugin_manager
      @plugin_manager ||=
        Plugin::Manager.factory.new(:main => self)
    end

    ##################################################################
    # Command runner
    #

    # The Cabar::Command::Runner that handles parsing arguments
    # and running the selected command.
    def command_runner
      @command_runner ||= 
        begin
          @command_runner = Command::Runner.factory.new(:context => self)
          
          define_standard_commands!
          
          @command_runner
        end
    end

    # Interface for bin/cbr.
    def parse_args args = self.args
      command_runner.parse_args(args)
    end

    # Interface for bin/cbr.
    def run<commit_msg>Load plugins before running any commands.<commit_after>require 'cabar/base'

require 'cabar/context'
require 'cabar/plugin'
require 'cabar/command/manager'
require 'cabar/command/runner'


module Cabar

  # Main bin/cbr script object.
  class Main < Base
    # Raw command line arguments from bin/cbr.
    attr_accessor :args

    # The Cabar::Command::Manager for top-level commands.
    attr_accessor :commands

    # The Cabar::Plugin::Manager.
    attr_accessor :plugin_manager

    def self.current
      @@current || raise(Error, "Cabar::Main not initialized")
    end

    def initialize *args
      @commands = Command::Manager.factory.
        new(:main => self, 
            :owner => self)

      super
      @@current = self

      import_standard_plugins!
    end

    def plugin_manager
      @plugin_manager ||=
        Plugin::Manager.factory.new(:main => self)
    end

    ##################################################################
    # Command runner
    #

    # The Cabar::Command::Runner that handles parsing arguments
    # and running the selected command.
    def command_runner
      @command_runner ||= 
        begin
          @command_runner = Command::Runner.factory.new(:context => self)
          
          context.avaliable_components
          
          @command_runner
        end
    end

    # Interface for bin/cbr.
    def parse_args args = self.args
      command_runner.parse_args(args)
    end

    # Interface for bin/cbr.
    def run
{'fraction_non_alphanumeric': 0.1300509337860781, 'fraction_numerical': 0.0, 'mean_word_length': 2.515513126491647, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '7354078', 'n_tokens_mistral': 859, 'n_tokens_neox': 799, 'n_words': 212}