Version 0.2.0: RDB_ICASE, Changelog, --version, angepasste Man-Pages

This commit is contained in:
wkh
2026-10-11 21:24:11 +02:00
parent b5b28798ac
commit 8f6dc852ff
18 changed files with 259 additions and 4 deletions
+16
View File
@@ -7,6 +7,7 @@ require 'open3'
require 'date'
require 'tmpdir'
require 'fileutils'
require_relative 'rdb/version'
module Rdb
ROOT = File.expand_path('..', __dir__)
@@ -16,6 +17,21 @@ module Rdb
COMMANDS = {}
class << self
# RDB_ICASE=1 makes column names match without regard to case. An exact
# match always wins; several case-insensitive matches are an error.
def icase?
!%w[0 no false].include?(ENV['RDB_ICASE'].to_s.downcase) && !ENV['RDB_ICASE'].to_s.empty?
end
def column_index(head, name)
exact = head.index(name)
return exact if exact || !icase?
hits = head.each_index.select { |i| head[i].casecmp?(name) }
die "column name '#{name}' is ambiguous: #{hits.map { |i| head[i] }.join(', ')}" if hits.size > 1
hits.first
end
def die(msg)
abort "#{File.basename($PROGRAM_NAME)}: #{msg}"
end