Sha256: af67e6b197fc92216ede7e39b7fdb2d3a3aa5ec85285a6b7e3cac64b56aa7297
Contents?: true
Size: 1.84 KB
Versions: 1
Compression:
Stored size: 1.84 KB
Contents
#! /usr/bin/ruby require 'clevic/browser.rb' require 'ruby-debug' require 'optparse' # find and require variations on file_path def require_if( file_path ) require file_path if File.exist?( file_path ) || File.exist?( file_path + '.rb' ) end $options = {} oparser = OptionParser.new oparser.banner = <<BANNER Usage: #{File.basename($0)} [options] model_definition_file model_definition_file, \#{model_definition_file}_models.rb will be searched for. Options are: BANNER oparser.separator '' oparser.on( '-H', '--host HOST', 'RDBMS host', String ) { |o| $options[:host] = o } oparser.on( '-u', '--user USERNAME', String ) { |o| $options[:user] = o } oparser.on( '-p', '--pass PASSWORD', String ) { |o| $options[:password] = o } oparser.on( '-t', '--table TABLE', 'Table to display', String ) { |o| $options[:table] = o } oparser.on( '-d', '--database DATABASE', 'Database name', String ) { |o| $options[:database] = o } oparser.on( '-D', '--debug' ) { |o| $options[:debug] = true } oparser.on( '-v', '--verbose' ) { |o| $options[:verbose] = true } oparser.on( '-h', '-?', '--help' ) do |o| puts oparser.to_s exit( 0 ) end args = oparser.parse( ARGV ) if args.size > 0 $options[:definition] = args.shift require_if "#{$options[:definition]}_models" require_if $options[:definition] else raise "no model definition file specified" end app = Qt::Application.new( args ) unless $options.has_key? :database raise "Please define $options[:database]" end # connect to db require 'clevic/db_options.rb' # show UI main_window = Qt::MainWindow.new browser = Clevic::Browser.new( main_window ) browser.open # this must come after Clevic::Browser.new main_window.window_title = $options[:database] main_window.show # make sure any partially edited records are saved when the window is closed app.connect( SIGNAL('lastWindowClosed()') ) { browser.save_all } app.exec
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clevic-0.5.2 | bin/clevic |