Sha256: 4f2cfbbef4f6145ed82664984448422cda60cca77dbb141c1d10700f12376af2

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

#!/usr/bin/env ruby

require "rubygems"
require "knjdbrevision"
require "knj/autoload"
Knj::Os.chdir_file(__FILE__)

begin
  options = {
    :dbargs => {
      :return_keys => "symbols"
    }
  }
  
  OptionParser.new do |opts|
    opts.banner = "Usage: example.rb [options]"
    
    opts.on("-t DBTYPE", "--type DBTYPE", "This database type.") do |t|
      options[:type] = t
    end
    
    opts.on("-d DBKEY=DBVALUE", "--dbarg DBKEY=DKVALUE", "Sets another database config key and value.") do |val|
      split_data = val.split("=")
      options[:dbargs][split_data.first.to_sym] = split_data.last
    end
    
    opts.on("-s FILEPATH", "A file with JSON content which contains the schema.") do |s|
      options[:schema_file] = s
      options[:schema] = JSON.parse(File.read(s))
    end
    
    opts.on("-r FILEPATH", "A Ruby file which sets the global variable $tables which contains the schema.") do |val|
      options[:rb_schema_file] = val
      require val
      options[:schema] = $tables
    end
  end.parse!
rescue OptionParser::InvalidOption => e
  print "#{e.message}\n"
  exit
end

dbrev.init_db(
  options[:schema],
  Knjdbrevision.new
)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
knjdbrevision-0.0.3 bin/run_with_schema.rb