<commit_before>require 'mysql2psql/errors'
require 'mysql2psql/version'
require 'mysql2psql/config'
require 'mysql2psql/converter'
require 'mysql2psql/mysqlreader'
require 'mysql2psql/writer'
require 'mysql2psql/postgres_writer'
require 'mysql2psql/postgres_db_writer.rb'
require 'mysql2psql/postgres_file_writer.rb'


class Mysql2psql
  
  attr_reader :options
  
  def initialize(args)
    configfile = args[0] || File.expand_path('config.yml')
    @options = Config.new( configfile, true )
  end
  
  def convert
    reader = MysqlReader.new( options )

    if options.destfile(nil)
      writer = PostgresFileWriter.new(options.destfile)
    else
      writer = PostgresDbWriter.new(
        options.pghostname('localhost'), options.pgusername, options.pgpassword, 
        options.pgdatabase, options.pgport(5432).to_i )
    end

    Converter.new(reader, writer, options).convert
  end

  def help
    puts <<EOS

EOS
  end
end<commit_msg>support help args<commit_after>require 'mysql2psql/errors'
require 'mysql2psql/version'
require 'mysql2psql/config'
require 'mysql2psql/converter'
require 'mysql2psql/mysqlreader'
require 'mysql2psql/writer'
require 'mysql2psql/postgres_writer'
require 'mysql2psql/postgres_db_writer.rb'
require 'mysql2psql/postgres_file_writer.rb'


class Mysql2psql
  
  attr_reader :options
  
  def initialize(args)
    help if args.length==1 && args[0] =~ /-.?|-*he?l?p?/i 
    configfile = args[0] || File.expand_path('config.yml')
    @options = Config.new( configfile, true )
  end
  
  def convert
    reader = MysqlReader.new( options )

    if options.destfile(nil)
      writer = PostgresFileWriter.new(options.destfile)
    else
      writer = PostgresDbWriter.new(
        options.pghostname('localhost'), options.pgusername, options.pgpassword, 
        options.pgdatabase, options.pgport(5432).to_i )
    end

    Converter.new(reader, writer, options).convert
  end

  def help
    puts <<EOS
MySQL to PostgreSQL Conversion

EOS
    exit -2
  end
end
{'fraction_non_alphanumeric': 0.10270541082164329, 'fraction_numerical': 0.016533066132264528, 'mean_word_length': 3.9430693069306932, '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': '2801033', 'n_tokens_mistral': 700, 'n_tokens_neox': 675, 'n_words': 134}