]> git.cworth.org Git - sup/commitdiff
added no-threads option to sup, which might be useful for debugging weird backtraces
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Fri, 11 May 2007 05:34:41 +0000 (05:34 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Fri, 11 May 2007 05:34:41 +0000 (05:34 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@396 5c8cc53c-5e98-4d25-b20a-d8db53a31250

bin/sup
lib/sup.rb

diff --git a/bin/sup b/bin/sup
index c565a784de0714038f11c2e4f67ea27727fdf604..e9638dbf71fa35c0bf85e26b045304f1ad28b402 100644 (file)
--- a/bin/sup
+++ b/bin/sup
@@ -2,8 +2,22 @@
 
 require 'rubygems'
 require 'ncurses'
+require 'trollop'
 require "sup"
 
+$opts = Trollop::options do
+  version "sup v#{Redwood::VERSION}"
+  banner <<EOS
+Sup is a curses-based email client.
+
+Usage:
+  sup [options]
+
+Options are:
+EOS
+  opt :no_threads, "Turn of threading. Helps with debugging. (Necessarily disables background polling for new messages.)"
+end
+
 Thread.abort_on_exception = true # make debugging possible
 
 module Redwood
@@ -126,7 +140,7 @@ begin
 
   imode.load_threads :num => ibuf.content_height, :when_done => lambda { reporting_thread { sleep 1; PollManager.poll } }
 
-  PollManager.start_thread
+  PollManager.start_thread unless $opts[:no_threads]
 
   until $exception
     bm.draw_screen
index 71c274f6ebf41d354a02a153ef0296d35b706286..fd898ae7cb1f1d3a52e6ae0e255b3d7eb657d699 100644 (file)
@@ -30,16 +30,20 @@ module Redwood
 ## record exceptions thrown in threads nicely
   $exception = nil
   def reporting_thread
-    ::Thread.new do
-      begin
-        yield
-      rescue Exception => e
-        File.open("sup-exception-log.txt", "w") do |f|
-          f.puts "--- #{e.class.name} at #{Time.now}"
-          f.puts e.message, e.backtrace
+    if $opts[:no_threads]
+      yield
+    else
+      ::Thread.new do
+        begin
+          yield
+        rescue Exception => e
+          File.open("sup-exception-log.txt", "w") do |f|
+            f.puts "--- #{e.class.name} at #{Time.now}"
+            f.puts e.message, e.backtrace
+          end
+          $exception ||= e
+          raise
         end
-        $exception ||= e
-        raise
       end
     end
   end