Sha256: 2b59a053328b53fef975bb72a164384d751fee83db53f7bf4687f06f9ec3f157

Contents?: true

Size: 1.06 KB

Versions: 13

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 = 100_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

13 entries across 13 versions & 1 rubygems

Version Path
sqlui-0.1.71 app/sqlui.rb
sqlui-0.1.70 app/sqlui.rb
sqlui-0.1.69 app/sqlui.rb
sqlui-0.1.68 app/sqlui.rb
sqlui-0.1.67 app/sqlui.rb
sqlui-0.1.66 app/sqlui.rb
sqlui-0.1.65 app/sqlui.rb
sqlui-0.1.64 app/sqlui.rb
sqlui-0.1.63 app/sqlui.rb
sqlui-0.1.62 app/sqlui.rb
sqlui-0.1.61 app/sqlui.rb
sqlui-0.1.60 app/sqlui.rb
sqlui-0.1.59 app/sqlui.rb