<commit_before># encoding: utf-8

module Gaku
  class Options
    VALID_OPTIONS = {
      deck: ['-d', '--deck'],
      stats: ['-s', '--stats']
    }

    attr_reader :options

    def initialize(argv)
      @options = {}
      invalid_options = []
      while arg = argv.shift
        if option = arg_hash[arg]
          argument = nil
          unless arg_hash[argv.first]
            argument = argv.shift
          end
          @options[option] = { argument: argument, form: arg }
        else
          invalid_options << arg
        end
      end
      invalid_options.empty? or raise InvalidOption, invalid_options
      ensure_options_valid(@options)
    end
<commit_msg>Set proper error message when options not valid<commit_after># encoding: utf-8

module Gaku
  class Options
    VALID_OPTIONS = {
      deck: ['-d', '--deck'],
      stats: ['-s', '--stats']
    }

    attr_reader :options

    def initialize(argv)
      @options = {}
      invalid_options = []
      while arg = argv.shift
        if option = arg_hash[arg]
          argument = nil
          unless arg_hash[argv.first]
            argument = argv.shift
          end
          @options[option] = { argument: argument, form: arg }
        else
          invalid_options << arg
        end
      end
      if not invalid_options.empty?
        msg = if invalid_options.length > 1
          "Invalid options #{invalid_options.map { |o| "'#{o}'" }.join(', ')}"
        else
          "Invalid option '#{invalid_options.first}'"
        end
        raise InvalidOption, msg
      end
      ensure_options_valid(@options)
    end

{'fraction_non_alphanumeric': 0.10820895522388059, 'fraction_numerical': 0.0018656716417910447, 'mean_word_length': 1.8680926916221035, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, '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': '3994473', 'n_tokens_mistral': 465, 'n_tokens_neox': 458, 'n_words': 124}