exe/arxutils_sqlite3 in arxutils_sqlite3-0.1.48 vs exe/arxutils_sqlite3 in arxutils_sqlite3-0.1.49
- old
+ new
@@ -6,84 +6,94 @@
require "ykutils"
require "ykxutils"
config = Arxutils_Sqlite3::Config.new
-cli = Arxutils_Sqlite3::Cli.new(config)
-
config.require_opts_file
-begin
- require "dbrelation"
-rescue LoadError => ex
- pp ex.message
+opts = @opts ? @opts : {}
+
+acrecord = opts[:acrecord]
+if acrecord
+ filename = acrecord[:filename]
+ basename = File.basename(filename)
+
+ begin
+ require "#{basename}"
+ rescue LoadError => ex
+ #pp ex.message
+ end
end
+opts[:db_dir] = Arxutils_Sqlite3::Config::DB_DIR
klass = nil
setting = config.load_setting_yaml_file
klass = setting[:klass]
# DBセットアップクラス
config.require_dbsetup_file
-banner = "Usage: bundle exec arxutils_sqlite3 --cmd=(s|c|m|i|d|b) -y yaml_file --klass=class"
+banner = "Usage: bundle exec arxutils_sqlite3 --cmd=(s|cds|co|c|f|m|a|d|b) -y yaml_file --klass=class"
-opts = @opts ? @opts : {}
-opts["dbconfig"] = Arxutils_Sqlite3::Config::DBCONFIG_SQLITE3
-
Simpleoptparse::Simpleoptparse.parse(ARGV, opts, banner, Arxutils_Sqlite3::VERSION, nil) do |parser|
- parser.on("--cmd X", %w[s c m i d b]) { |x| opts["cmd"] = x }
+ parser.on("--cmd X", %w[s cds co c f m a d b]) { |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
klass = opts["klass"] if opts["klass"]
+dbconfig = Arxutils_Sqlite3::Config::DBCONFIG_SQLITE3
env = ENV.fetch("ENV", nil)
env ||= "production"
+cli = Arxutils_Sqlite3::Cli.new(config, dbconfig, env)
+
case opts["cmd"]
when "s"
- config.check_file_exist(Arxutils_Sqlite3::Config::DEST_OPTS_FILE, banner, 10)
+ #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"
- dbconfig = opts["dbconfig"]
- relation = opts["relation"]
- cli.makeconfig(dbconfig, relation, banner, 30, opts)
+ acrecord = opts[:acrecord]
+ cli.makeconfig(acrecord, banner, 30, opts)
-when "m"
+when "f"
yaml_fname = opts["yaml"]
- relation = opts[:relation]
- dbconfig = opts["dbconfig"]
+ acrecord = opts[:acrecord]
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.setup_for_migrate(yaml_pn, acrecord, klass)
- cli.migrate(yaml_pn, relation, klass, dbconfig, env)
+when "m"
+ cli.migrate
-when "i"
- dbconfig = opts["dbconfig"]
- cli.integrate(dbconfig, env)
+when "a"
+ cli.acr
when "d"
db_scheme_ary = nil
- dbconfig = opts["dbconfig"]
- relation = opts["relation"]
- cli.delete(dbconfig, db_scheme_ary, relation)
+ acrecord = opts["acrecord"]
+ cli.delete(db_scheme_ary, acrecord)
when "b"
db_scheme_ary = nil
- dbconfig = opts["dbconfig"]
- relation = opts["relation"]
- cli.delete_db(dbconfig, db_scheme_ary, relation)
+ acrecord = opts["acrecord"]
+ cli.delete_db(db_scheme_ary, acrecord)
else
puts "Invalid command(#{opts["cmd"]}) specified!!"
end