<commit_before>require 'set'

require 'slop/option'

class Slop
  VERSION = '0.1.4'

  # Raised when an option expects an argument and none is given
  class MissingArgumentError < ArgumentError; end

  # @return [Set]
  attr_reader :options

  # @return [Set] the last set of options used
  def self.options
    @@options
  end

  # Sugar for new(..).parse(stuff)
  def self.parse(values=[], &blk)
    new(&blk).parse(values)
  end

  def initialize(&blk)
    @options = Set.new
    @@options = @options
    instance_eval(&blk) if block_given?
  end

  # add an option
  def option(*args, &blk)
    opts = args.pop if args.last.is_a?(Hash)
    opts ||= {}

    if args.size > 4
      raise ArgumentError, "Argument size must be no more than 4"
    end

    args.unshift nil if args.first.size > 1
    args.push nil if args.size == 2
    args.push false if args.size == 3

    args[2..3] = [nil, true] if args[2] == true

    attributes = [:flag, :option, :description, :argument]
    options = Hash[attributes.zip(args)]
    options.merge!(opts)
    options[:as] = options[:default].class if options.key?(:default)
    options[:callback] = blk if block_given?

    @options << Option.new(options)
  end
  alias :opt :option
  alias :o :option

  # add an argument
  def argument(*args)

  end
  alias :arg :argument
  alias :args :argument
  alias :arguments :argument

  # Parse an Array (usually ARGV) of options
  #
  # @param [Array, #split] Array or String of options to parse
  def parse(values=[])<commit_msg>added parse raise documentation<commit_after>require 'set'

require 'slop/option'

class Slop
  VERSION = '0.1.4'

  # Raised when an option expects an argument and none is given
  class MissingArgumentError < ArgumentError; end

  # @return [Set]
  attr_reader :options

  # @return [Set] the last set of options used
  def self.options
    @@options
  end

  # Sugar for new(..).parse(stuff)
  def self.parse(values=[], &blk)
    new(&blk).parse(values)
  end

  def initialize(&blk)
    @options = Set.new
    @@options = @options
    instance_eval(&blk) if block_given?
  end

  # add an option
  def option(*args, &blk)
    opts = args.pop if args.last.is_a?(Hash)
    opts ||= {}

    if args.size > 4
      raise ArgumentError, "Argument size must be no more than 4"
    end

    args.unshift nil if args.first.size > 1
    args.push nil if args.size == 2
    args.push false if args.size == 3

    args[2..3] = [nil, true] if args[2] == true

    attributes = [:flag, :option, :description, :argument]
    options = Hash[attributes.zip(args)]
    options.merge!(opts)
    options[:as] = options[:default].class if options.key?(:default)
    options[:callback] = blk if block_given?

    @options << Option.new(options)
  end
  alias :opt :option
  alias :o :option

  # add an argument
  def argument(*args)

  end
  alias :arg :argument
  alias :args :argument
  alias :arguments :argument

  # Parse an Array (usually ARGV) of options
  #
  # @param [Array, #split] Array or String of options to parse
  # @raise [MissingArgumentError] raised when a compulsory argument is missing
  def parse(values=[])
{'fraction_non_alphanumeric': 0.11888782358581017, 'fraction_numerical': 0.007031000319590924, 'mean_word_length': 3.14021164021164, 'pattern_counts': {'":': 0, '<': 9, '<?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': '1241731', 'n_tokens_mistral': 1055, 'n_tokens_neox': 996, 'n_words': 335}