<commit_before>require 'optparse'
require 'trooper/configuration'

module Trooper
  class CLI

    def self.start(argv = ARGV)
      cli = self.new(argv)
      cli.execute
      cli
    end

    attr_reader :command, :options, :argv
    attr_accessor :config

    def initialize(argv)
      @argv = argv
      @options = { :environment => :production }

      @command = option_parser.parse!(@argv)[0]
      raise CliArgumentError, "You didnt pass an action" if @command == nil
    end

    def execute
      case command.to_sym
      when :init
        Configuration.init
      else
        config = Configuration.new(options)
        config.execute action
      end
    end

    private

    def option_parser
      @option_parser ||= ::OptionParser.new do |op|
        op.banner = 'Usage: trooper <command> [options]'      
        op.separator ''

        op.on "-d", "--debug", "Debuy" do 
          @options[:debug] = true
        end

        op.on "-e", "--env ENV", "Environment" do |e|
          @options[:environment] = e.to_sym
        end

        op.on_tail "-h", "--help", "Help" do 
          puts @option_parser
          exit
        end

        op.on_tail "-v", "--version", "Show version" do
          puts "Trooper v#{Trooper::Version::STRING}"
          exit
        end

      end
    end

  end
end<commit_msg>add file override option to cli<commit_after>require 'optparse'
require 'trooper/configuration'

module Trooper
  class CLI

    def self.start(argv = ARGV)
      cli = self.new(argv)
      cli.execute
      cli
    end

    attr_reader :command, :options, :argv
    attr_accessor :config

    def initialize(argv)
      @argv = argv
      @options = { :environment => :production }

      @command = option_parser.parse!(@argv)[0]
      raise CliArgumentError, "You didnt pass an action" if @command == nil
    end

    def execute
      case command.to_sym
      when :init
        Configuration.init
      else
        config = Configuration.new(options)
        config.execute action
      end
    end

    private

    def option_parser
      @option_parser ||= ::OptionParser.new do |op|
        op.banner = 'Usage: trooper <command> [options]'      
        op.separator ''

        op.on "-d", "--debug", "Debuy" do 
          @options[:debug] = true
        end

        op.on "-e", "--env ENV", "Environment" do |e|
          @options[:environment] = e.to_sym
        end

        op.on "-f", "--file TROOPFILE", "Load a different Troopfile" do |f|
          @options[:file_name] = f || 'Troopfile' 
        end

        op.on_tail "-h", "--help", "Help" do 
          puts @option_parser
          exit
        end

        op.on_tail "-v", "--version", "Show version" do
          puts "Trooper v#{Trooper::Version::STRING}"
          exit
        end

      end
    end

  end
end
{'fraction_non_alphanumeric': 0.11421499292786422, 'fraction_numerical': 0.0007072135785007072, 'mean_word_length': 1.8691683569979716, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6770259', 'n_tokens_mistral': 891, 'n_tokens_neox': 842, 'n_words': 240}