<commit_before># typed: true
# frozen_string_literal: true

require "cli/parser"

module Homebrew
  extend T::Sig

  module_function

  SUPPORTED_REPOS = %w[brew core cask bundle].freeze

  sig { returns(CLI::Parser) }
  def contributions_args
    Homebrew::CLI::Parser.new do
      usage_banner <<~EOS
        `contributions [email]`

        Contributions to Homebrew repos for a user.
      EOS

      flag "--from=",
           description: "Date (ISO-8601 format) to start searching contributions."

      flag "--to=",
           description: "Date (ISO-8601 format) to stop searching contributions."

      comma_array "--repos=",
                  description: "The Homebrew repositories to search for contributions in. " \
                               "Comma separated. Supported repos: #{SUPPORTED_REPOS.join(", ")}."

      named_args :email
    end
  end

  sig { returns(NilClass) }
  def contributions
    args = contributions_args.parse

    return ofail "`--repos` is required." if args[:repos].empty?

    commits = 0
    coauthorships = 0

    args[:repos].each do |repo|
      if SUPPORTED_REPOS.exclude?(repo)
        return ofail "Unsupported repo: #{repo}. Try one of #{SUPPORTED_REPOS.join(", ")}."
      end

      repo_path = find_repo_path_for_repo(repo)<commit_msg>dev-cmd/contributions: Only one email is allowed currently<commit_after># typed: true
# frozen_string_literal: true

require "cli/parser"

module Homebrew
  extend T::Sig

  module_function

  SUPPORTED_REPOS = %w[brew core cask bundle].freeze

  sig { returns(CLI::Parser) }
  def contributions_args
    Homebrew::CLI::Parser.new do
      usage_banner <<~EOS
        `contributions [email]`

        Contributions to Homebrew repos for a user.
      EOS

      flag "--from=",
           description: "Date (ISO-8601 format) to start searching contributions."

      flag "--to=",
           description: "Date (ISO-8601 format) to stop searching contributions."

      comma_array "--repos=",
                  description: "The Homebrew repositories to search for contributions in. " \
                               "Comma separated. Supported repos: #{SUPPORTED_REPOS.join(", ")}."

      named_args :email, number: 1
    end
  end

  sig { returns(NilClass) }
  def contributions
    args = contributions_args.parse

    return ofail "`--repos` is required." if args[:repos].empty?

    commits = 0
    coauthorships = 0

    args[:repos].each do |repo|
      if SUPPORTED_REPOS.exclude?(repo)
        return ofail "Unsupported repo: #{repo}. Try one of #{SUPPORTED_REPOS.join(", ")}."
      end

      repo_path = find_repo_path_for_repo(repo)
{'fraction_non_alphanumeric': 0.10627836611195159, 'fraction_numerical': 0.00794251134644478, 'mean_word_length': 2.628257887517147, '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': '1775546', 'n_tokens_mistral': 833, 'n_tokens_neox': 767, 'n_words': 225}