Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 70 lines (53 sloc) 1.746 kb
#!/usr/bin/env ruby
require File.expand_path( "../../lib/couchup", __FILE__)
require 'irb'
require 'irb/completion'
require 'optparse'
if File.exists? ".irbrc"
ENV['IRBRC'] = ".irbrc"
end
if File.exists?( File.expand_path(rcfile = "~/.couchuprc") )
load(rcfile)
end
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: example.rb [options]"
opts.on("-h", "--host HOST", "Host to connect to (Defaults to localhost)") do |h|
options[:host] = h
end
opts.on("-p", "--port PORT", "Port to connect to (Defaults to 5984)") do |port|
options[:port] = port
end
opts.on("-d", "--database DATABASE", "Database to connect to.") do |db|
options[:db] = db
end
opts.on("-u", "--username USER", "Database to connect to.") do |user|
options[:user] = user
end
opts.on("-a", "--password PASSWORD", "Database to connect to.") do |password|
options[:password] = password
end
opts.on("-b", "--debug", "Show debugging information") do |bug|
options[:bug] = bug
end
opts.on("-c", "--command COMMAND", "Runs a specific command and prints the result, seperate with ';' to run multiple commands") do |c|
options[:command] = c
end
end.parse!
host = options[:host] || 'localhost'
port = options[:port] || "5984"
Couchup::Commands::Connect.new.run(host, port, options[:user], options[:password])
Couchup::Commands::Use.new.run(options[:db]) unless options[:db].nil?
Couchup::Couchup.debug = true if options[:bug]
unless(options[:command].nil?)
commands = options[:command].split( ";")
commands.each do |command|
c, params = command.split
ap send(c, *params)
end
exit
end
ap "Type help to view the list of things you can do. And Yeah Relax."
ARGV.clear
IRB.start
exit!
Jump to Line
Something went wrong with that request. Please try again.