Sha256: c50557d7b2f97b69c48294dd70c8754c5e47e6ea9a145d8d29dca7898e8fcfb2

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

require_relative 'sqlui_config'
require_relative 'server'
require_relative 'version'

# Main entry point.
class Sqlui
  MAX_ROWS = 50_000
  MAX_BYTES = 10 * 1_024 * 1_024 # 10 MB

  def initialize(config_file)
    raise 'you must specify a configuration file' unless config_file
    raise 'configuration file does not exist' unless File.exist?(config_file)

    @config = SqluiConfig.new(config_file)
    @resources_dir = File.join(File.expand_path('..', File.dirname(__FILE__)), 'client', 'resources')

    # Connect to each database to verify each can be connected to.
    @config.database_configs.each { |database| database.with_client { |client| client } }
  end

  def run
    Server.init_and_run(@config, @resources_dir)
  end

  def self.from_command_line(args)
    if args.include?('-v') || args.include?('--version')
      puts Version::SQLUI
      exit
    end

    raise 'you must specify a configuration file' unless args.size == 1
    raise 'configuration file does not exist' unless File.exist?(args[0])

    Sqlui.new(args[0])
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sqlui-0.1.58 app/sqlui.rb
sqlui-0.1.57 app/sqlui.rb