From cb6e52400dbcc52fcecaca86508e1d5d92cf5c1d Mon Sep 17 00:00:00 2001 From: V Sreekanth Date: Mon, 28 Feb 2011 10:53:07 +0530 Subject: [PATCH] Adding a debug flag --- bin/couchup | 6 +++++- lib/couchup.rb | 2 +- lib/couchup/couchup.rb | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/couchup b/bin/couchup index 0054cd3..8a2fa69 100755 --- a/bin/couchup +++ b/bin/couchup @@ -29,6 +29,10 @@ 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! @@ -36,7 +40,7 @@ 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 diff --git a/lib/couchup.rb b/lib/couchup.rb index 16ce34d..752bf05 100644 --- a/lib/couchup.rb +++ b/lib/couchup.rb @@ -14,7 +14,7 @@ def #{c.underscore}(*args) instance.run(*args) rescue puts $!.inspect - puts $!.backtrace + puts $!.backtrace if Couchup.debug? end end" end diff --git a/lib/couchup/couchup.rb b/lib/couchup/couchup.rb index d4b906b..14fbc0c 100644 --- a/lib/couchup/couchup.rb +++ b/lib/couchup/couchup.rb @@ -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