Module: DBAdmin
- Defined in:
- lib/dbadmin.rb,
lib/dbadmin/app.rb
Defined Under Namespace
Classes: App
Constant Summary collapse
- VERSION =
"0.2.0"
Class Method Summary collapse
Class Method Details
.start(argv) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/dbadmin.rb', line 12 def self.start(argv) = { :Host => "localhost", :Port => 8888, :daemonize => true } parser = OptionParser.new do |o| o.on "-p", "--port PORT", "The port to run the web server on" do |arg| [:Port] = arg.to_i end o.on "-h", "--host HOST", "The host to run the web server on" do |arg| [:Host] = arg end o.on "-f", "--foreground", "Run server in the foreground" do |arg| [:daemonize] = arg ? false : true end o. = "Usage: dbadmin [options] [db_url]\n\nExample: dbadmin -p 8080 mysql://user:pass@host/db\n\n" o.on_tail "--help", "Show help" do puts o exit 1 end end url = parser.parse(argv).first ENV['DATABASE_URL'] = url if url puts "Starting DB Admin #{VERSION} at http://#{options[:Host]}:#{options[:Port]}" Rack::Server.start(.merge(app: DBAdmin::App)) end |