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
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
## 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