<commit_before>$LOAD_PATH << __dir__ + '/..'

require 'workerholic'
require 'optparse'
require 'singleton'

module Workerholic
  class CLI
    include Singleton

    attr_reader :logger, :options

    def initialize
      @logger = LogManager.new
    end

    def run
      parse_options
      set_options

      load_app

      Manager.new(auto_balance: options[:auto_balance]).start
    end

    def parse_options
      @options = {}

      OptionParser.new do |opts|
        opts.banner = 'Usage: workerholic [options]'

        opts.on '-ab', '--auto-balance', 'auto-balance workers based on number of jobs in each queue' do
          options[:auto_balance] = true
        end

        opts.on '-w', '--workers INT', 'number of concurrent workers' do |count|
          options[:workers] = count.to_i
        end

        opts.on '-r', '--require PATH', 'file to be required to load your application' do |file|
          options[:require] = file
        end

        opts.on '-h', '--help', 'show help' do
          logger.info(opts)
          exit
        end
      end.parse!
    end

    def set_options
      Workerholic.workers_count = options[:workers_count] if options[:workers_count]
    end

    def load_app
      if File.exist?('./config/environment.rb')
        require File.expand_path('./config/environment.rb')
        require 'workerholic/adapters/active_job_adapter'
      elsif options[:require]
        if File.exist?(options[:require])
          require File.expand_path(options[:require])
        else
          log.info('The file you specified to load your application is not valid!')
          exit
        end
      else
        logger.info('If you are using a Rails app, make sure to navigate to your root directory before starting Workerholic!')
        logger.info('If you are not using a Rails app, you can load your app by using the option --require and specifying the file needing to be required in order to load your application.')

        exit
      end
    end
  end
end<commit_msg>check user required file by using absolute path<commit_after>$LOAD_PATH << __dir__ + '/..'

require 'workerholic'
require 'optparse'
require 'singleton'

module Workerholic
  class CLI
    include Singleton

    attr_reader :logger, :options

    def initialize
      @logger = LogManager.new
    end

    def run
      parse_options
      set_options

      load_app

      Manager.new(auto_balance: options[:auto_balance]).start
    end

    def parse_options
      @options = {}

      OptionParser.new do |opts|
        opts.banner = 'Usage: workerholic [options]'

        opts.on '-ab', '--auto-balance', 'auto-balance workers based on number of jobs in each queue' do
          options[:auto_balance] = true
        end

        opts.on '-w', '--workers INT', 'number of concurrent workers' do |count|
          options[:workers] = count.to_i
        end

        opts.on '-r', '--require PATH', 'file to be required to load your application' do |file|
          options[:require] = file
        end

        opts.on '-h', '--help', 'show help' do
          logger.info(opts)
          exit
        end
      end.parse!
    end

    def set_options
      Workerholic.workers_count = options[:workers_count] if options[:workers_count]
    end

    def load_app
      if File.exist?('./config/environment.rb')
        require File.expand_path('./config/environment.rb')

        require 'workerholic/adapters/active_job_adapter'

        ActiveSupport.run_load_hooks(:before_eager_load, Rails.application)
        Rails.application.config.eager_load_namespaces.each(&:eager_load!)
      elsif options[:require]
        file_path = File.expand_path(options[:require])

        if File.exist?(file_path)
          require file_path
        else
          logger.info('The file you specified to load your application is not valid!')

          exit
        end
      else
        logger.info('If you are using a Rails app, make sure to navigate to your root directory before starting Workerholic!')
        logger.info('If you are not using a Rails app, you can load your app by using the option --require and specifying the file needing to be required in order to load your application.')

        exit
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09101599247412982, 'fraction_numerical': 0.0, 'mean_word_length': 2.3488188976377953, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1513073', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1164, 'n_words': 389}