Sha256: 725f1985f992666a54a33974855a476bab4b8c16943927bc58de85c8f82d73fa

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require_relative 'sqlui_config'
require_relative 'server'

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

  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 File.read('.version')
      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

6 entries across 6 versions & 1 rubygems

Version Path
sqlui-0.1.52 app/sqlui.rb
sqlui-0.1.51 app/sqlui.rb
sqlui-0.1.50 app/sqlui.rb
sqlui-0.1.49 app/sqlui.rb
sqlui-0.1.48 app/sqlui.rb
sqlui-0.1.47 app/sqlui.rb