Sha256: 05fe483bafada112788ab8bc16849854c900eb06501a160ec32a8ca55ae60ddf

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

#!/usr/bin/env ruby

require "arxutils_sqlite3"
require "simpleoptparse"
require "pp"
require "ykutils"
require "ykxutils"

config = Arxutils_Sqlite3::Config.new

opts, klass = config.setupx(self)
# p opts
# p klass
# exit

banner = "Usage: bundle exec arxutils_sqlite3 --cmd=(s|cds|co|c|f|m|a|d|b|y|dm) -y yaml_file --klass=class"

Simpleoptparse::Simpleoptparse.parse(ARGV, opts, banner, Arxutils_Sqlite3::VERSION, nil) do |parser|
  parser.on("--cmd X", %w[s cds co c f m a d b y dm]) { |x| opts["cmd"] = x }
  parser.on("-y yaml_file", "--yaml yaml_file") { |x| opts["yaml"] = x }
  parser.on("--klass klass") { |x| opts["klass"] = x }
end

dbconfig = Arxutils_Sqlite3::Config::DBCONFIG_SQLITE3
env = ENV.fetch("ENV", nil)
env ||= "production"

acrecord = opts[:acrecord]
yaml_fname = opts["yaml"]
klass = opts["klass"]
cli = Arxutils_Sqlite3::Cli.new(config, dbconfig, env, acrecord, yaml_fname, klass)

case opts["cmd"]
when "s"
  # config.check_file_exist(Arxutils_Sqlite3::Config::SAMPLE_DEST_OPTS_FILE, banner, 10)

  if opts["klass"].nil? || opts["klass"].strip == ""
    puts banner
    exit 20
  end
  cli.setup(klass)

when "cds"
  cli.copy_db_scheme

when "co"
  cli.copy_opts_file

when "c"
  cli.makeconfig(opts)

when "f"
  if yaml_fname.nil? || yaml_fname.strip == ""
    puts banner
    exit 40
  end
  yaml_pn = Pathname.new(yaml_fname)
  config.check_file_not_exist(yaml_pn, banner, 55)
  cli.make_migrate_script
when "m"
  cli.migrate

when "a"
  cli.acr

when "d"
  cli.delete

when "b"
  cli.delete_db

when "y"
  cli.delete_setting_yaml

when "dm"
  cli.delete_migrate

else
  puts "Invalid command(#{opts["cmd"]}) specified!!"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arxutils_sqlite3-0.1.56 exe/arxutils_sqlite3