sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 58e9f5c7ec21e88bb709681dab6f7f695cac8af7
parent 76155fc9c0d00251c8cc8dd5737494b1ffc5e364
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date:   Fri, 11 May 2007 05:34:41 +0000

added no-threads option to sup, which might be useful for debugging weird backtraces

git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@396 5c8cc53c-5e98-4d25-b20a-d8db53a31250

Diffstat:
M bin/sup | 16 +++++++++++++++-
M lib/sup.rb | 22 +++++++++++++---------
2 files changed, 28 insertions(+), 10 deletions(-)
diff --git 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
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -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