mongo-ruby-driver/bin/mongo_console

22 lines
567 B
Plaintext
Raw Normal View History

#!/usr/bin/env ruby
org_argv = ARGV.dup
ARGV.clear
require 'irb'
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo'
include Mongo
host = org_argv[0] || ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = org_argv[1] || ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
dbnm = org_argv[2] || ENV['MONGO_RUBY_DRIVER_DB'] || 'ruby-mongo-console'
puts "Connecting to #{host}:#{port} (CONN) on with database #{dbnm} (DB)"
CONN = Connection.new(host, port)
DB = CONN.db(dbnm)
puts "Starting IRB session..."
2008-12-08 21:58:16 +00:00
IRB.start(__FILE__)