conf with Usage
This commit is contained in:
parent
8c35b1d646
commit
520a70fa53
1 changed files with 5 additions and 2 deletions
|
@ -6,12 +6,15 @@ conf = {}
|
||||||
%w[etc sids].each {|key| conf[key.to_sym] = key }
|
%w[etc sids].each {|key| conf[key.to_sym] = key }
|
||||||
conf[:sids] = File.basename( conf[:sids], ".cnf")+".cnf"
|
conf[:sids] = File.basename( conf[:sids], ".cnf")+".cnf"
|
||||||
|
|
||||||
$stdout.puts ARGV.inspect
|
if ARGV[0].nil? or ARGV[0].empty?
|
||||||
|
$stderr.puts "Usage: #{$0} DATABASE [SID [VALUE]]"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
|
||||||
|
Dir.mkdir conf[:etc] rescue Errno::EEXIST
|
||||||
SBDB::Env.open( conf[:etc], SBDB::CREATE | SBDB::Env::INIT_TXN | Bdb::DB_INIT_MPOOL,
|
SBDB::Env.open( conf[:etc], SBDB::CREATE | SBDB::Env::INIT_TXN | Bdb::DB_INIT_MPOOL,
|
||||||
log_config: SBDB::Env::LOG_IN_MEMORY | SBDB::Env::LOG_AUTO_REMOVE) do |etc|
|
log_config: SBDB::Env::LOG_IN_MEMORY | SBDB::Env::LOG_AUTO_REMOVE) do |etc|
|
||||||
etc.recno( conf[:sids], ARGV[0], flags: SBDB::CREATE | SBDB::AUTO_COMMIT) do |db|
|
etc.recno( conf[:sids], ARGV[0], flags: SBDB::CREATE | SBDB::AUTO_COMMIT) do |db|
|
||||||
$stderr.puts db.inspect
|
|
||||||
if ARGV[2]
|
if ARGV[2]
|
||||||
db[ ARGV[1].to_i] = ARGV[2].empty? ? nil : ARGV[2]
|
db[ ARGV[1].to_i] = ARGV[2].empty? ? nil : ARGV[2]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue