class SchemaExtractor::OptionParser

Public Instance Methods

parse(args) click to toggle source
# File lib/schema_extractor/option_parser.rb, line 10
def parse(args)
  parser.parse(args)
end

Private Instance Methods

banner() click to toggle source
formats() click to toggle source
# File lib/schema_extractor/option_parser.rb, line 20
def formats
  Formatters.formats.join(", ")
end
options() click to toggle source
# File lib/schema_extractor/option_parser.rb, line 24
def options
  Slop::Options.new do |o|
    o.banner = banner

    o.string(
      "-s",
      "--source",
      "Source database type. Supported sources: #{sources}",
      default: "mysql"
    )
    o.string(
      "-f",
      "--format",
      "Output format. Supported formats: #{formats}",
      default: "bigquery"
    )
    o.string(
      "-o",
      "--output",
      "Output directory.",
      default: "."
    )

    o.string "-h", "--host", "Host of database."
    o.string "-u", "--user", "User of database."
    o.string "-p", "--password", "Password of database."
    o.string "-P", "--port", "Port of database."
    o.string "-d", "--database", "Database name."

    o.on "-v", "--version", "Show version." do
      require "schema_extractor/version"
      puts SchemaExtractor::VERSION
      exit
    end

    o.on "--help", "Show this message." do
      puts o
      exit
    end
  end
end
parser() click to toggle source
# File lib/schema_extractor/option_parser.rb, line 66
def parser
  Slop::Parser.new(options)
end
sources() click to toggle source
# File lib/schema_extractor/option_parser.rb, line 70
def sources
  Extractors.sources.join(", ")
end