Skip to content

Commit

Permalink
Adding a debug flag
Browse files Browse the repository at this point in the history
  • Loading branch information
sreeix committed Feb 28, 2011
1 parent 69885d9 commit cb6e524
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion bin/couchup
Expand Up @@ -29,14 +29,18 @@ OptionParser.new do |opts|
opts.on("-d", "--database DATABASE", "Database to connect to.") do |db|
options[:db] = db
end

opts.on("-b", "--debug", "Show debugging information") do |bug|
options[:bug] = bug
end

end.parse!

host = options[:host] || 'localhost'
port = options[:port] || "5984"
Couchup::Commands::Connect.new.run(host, port)
Couchup::Commands::Use.new.run(options[:db]) unless options[:db].nil?

Couchup.debug = true if options[:bug]
puts "Type help to view the list of things you can do. And Yeah Relax."

ARGV.clear
Expand Down
2 changes: 1 addition & 1 deletion lib/couchup.rb
Expand Up @@ -14,7 +14,7 @@ def #{c.underscore}(*args)
instance.run(*args)
rescue
puts $!.inspect
puts $!.backtrace
puts $!.backtrace if Couchup.debug?
end
end"
end
6 changes: 6 additions & 0 deletions lib/couchup/couchup.rb
Expand Up @@ -50,6 +50,12 @@ def get(id)
def all(options={})
@db.documents(options)
end
def debug=(value)
@debug = value
end
def debug?
@debug == true
end

def databases
server.databases
Expand Down

0 comments on commit cb6e524

Please sign in to comment.