<commit_before>#!/usr/bin/env ruby

require "optparse"
require "ostruct"
require "stringio"
require "tempfile"
require "time"
require "net/smtp"
require "socket"

SMTP_PORT = 25

class OptionParser
  class CannotCoexistOption < ParseError
    const_set(:Reason, 'cannot coexist option'.freeze)
  end
end

def parse_args(args)
  options = OpenStruct.new
  options.to = []
  options.error_to = []
  options.from = nil
  options.from_domain = nil
  options.add_diff = true
  options.repository_uri = nil
  options.rss_path = nil
  options.rss_uri = nil
  options.name = nil
  options.use_utf8 = false
  options.server = "localhost"
  options.port = SMTP_PORT

  opts = OptionParser.new do |opts|
    opts.banner += " REPOSITORY_PATH REVISION TO"

    opts.separator ""
    opts.separator "E-mail related options:"

    opts.on("-sSERVER", "--server=SERVER",
            "Use SERVER as SMTP server (#{options.server})") do |server|
      options.server = server
    end

    opts.on("-pPORT", "--port=PORT", Integer,
            "Use PORT as SMTP port (#{options.port})") do |port|
      options.port = port
    end

    opts.on("-tTO", "--to=TO", "Add TO to to address") do |to|
      options.to << to unless to.nil?
    end

    opts.on("-eTO", "--error-to=TO",
            "Add TO to to address when an error is",
            "occurred") do |to|
      options.error_to << to unless to.nil?
    end

    opts.on("-fFROM", "--from=FROM", "Use FROM as from address") do |from|
      if options.from_domain
        raise OptionParser::CannotCoexistOption,
              "cannot coexist with --from-domain"
      end
      options.from = from
    end

    opts.on("--from-domain=DOMAIN",
            "Use author@DOMAIN as from address") do |domain|
      if options.from
        raise OptionParser::CannotCoexistOption,
              "cannot coexist with --from"<commit_msg>* tools/hook-scripts/commit-email.rb   (parse_args): Improve option description.<commit_after>#!/usr/bin/env ruby

require "optparse"
require "ostruct"
require "stringio"
require "tempfile"
require "time"
require "net/smtp"
require "socket"

SMTP_PORT = 25

class OptionParser
  class CannotCoexistOption < ParseError
    const_set(:Reason, 'cannot coexist option'.freeze)
  end
end

def parse_args(args)
  options = OpenStruct.new
  options.to = []
  options.error_to = []
  options.from = nil
  options.from_domain = nil
  options.add_diff = true
  options.repository_uri = nil
  options.rss_path = nil
  options.rss_uri = nil
  options.name = nil
  options.use_utf8 = false
  options.server = "localhost"
  options.port = SMTP_PORT

  opts = OptionParser.new do |opts|
    opts.banner += " REPOSITORY_PATH REVISION TO"

    opts.separator ""
    opts.separator "E-mail related options:"

    opts.on("-sSERVER", "--server=SERVER",
            "Use SERVER as SMTP server (#{options.server})") do |server|
      options.server = server
    end

    opts.on("-pPORT", "--port=PORT", Integer,
            "Use PORT as SMTP port (#{options.port})") do |port|
      options.port = port
    end

    opts.on("-tTO", "--to=TO", "Add TO to To: address") do |to|
      options.to << to unless to.nil?
    end

    opts.on("-eTO", "--error-to=TO",
            "Add TO to To: address when an error is",
            "occurred") do |to|
      options.error_to << to unless to.nil?
    end

    opts.on("-fFROM", "--from=FROM", "Use FROM as from address") do |from|
      if options.from_domain
        raise OptionParser::CannotCoexistOption,
              "cannot coexist with --from-domain"
      end
      options.from = from
    end

    opts.on("--from-domain=DOMAIN",
            "Use author@DOMAIN as from address") do |domain|
      if options.from
        raise OptionParser::CannotCoexistOption,
              "cannot coexist with --from"
{'fraction_non_alphanumeric': 0.12562417871222076, 'fraction_numerical': 0.0015768725361366622, 'mean_word_length': 2.6808510638297873, 'pattern_counts': {'":': 0, '<': 13, '<?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': '4607064', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1206, 'n_words': 340}