bin/sup in sup-0.9.1 vs bin/sup in sup-0.10

- old
+ new

@@ -1,26 +1,23 @@ #!/usr/bin/env ruby require 'rubygems' -require 'ncurses' -require 'curses' + +no_ncursesw = false +begin + require 'ncursesw' +rescue LoadError + require 'ncurses' + no_ncursesw = true +end + require 'fileutils' require 'trollop' -require "sup" +require "sup"; Redwood::check_library_version_against "0.10" -BIN_VERSION = "0.9.1" - -unless Redwood::VERSION == BIN_VERSION - $stderr.puts <<EOS - -Error: version mismatch! -The sup executable is at version #{BIN_VERSION.inspect}. -The sup libraries are at version #{Redwood::VERSION.inspect}. - -Is your development environment conflicting with rubygems? -EOS - exit(-1) +if no_ncursesw + debug "No 'ncursesw' gem detected. Install it for wide character support." end $opts = Trollop::options do version "sup v#{Redwood::VERSION}" banner <<EOS @@ -35,10 +32,11 @@ opt :no_threads, "Turn off threading. Helps with debugging. (Necessarily disables background polling for new messages.)" opt :no_initial_poll, "Don't poll for new messages when starting." opt :search, "Search for this query upon startup", :type => String opt :compose, "Compose message to this recipient upon startup", :type => String opt :subject, "When composing, use this subject", :type => String, :short => "j" + opt :index, "Use this index type ('auto' for autodetect)", :default => "auto" end Trollop::die :subject, "requires --compose" if $opts[:subject] && !$opts[:compose] Redwood::HookManager.register "startup", <<EOS @@ -77,10 +75,11 @@ k.add :redraw, "Redraw screen", :ctrl_l k.add :search, "Search all messages", '\\', 'F' k.add :search_unread, "Show all unread messages", 'U' k.add :list_labels, "List labels", 'L' k.add :poll, "Poll for new messages", 'P' + k.add :poll_unusual, "Poll for new messages from unusual sources", '{' k.add :compose, "Compose new message", 'm', 'c' k.add :nothing, "Do nothing", :ctrl_g k.add :recall_draft, "Edit most recent draft message", 'R' k.add :show_inbox, "Show the Inbox buffer", 'I' k.add :show_console, "Show the Console buffer", '~' @@ -133,16 +132,44 @@ Ncurses.echo Ncurses.endwin end module_function :start_cursing, :stop_cursing -Index.init +Index.init $opts[:index] Index.lock_interactively or exit +if Index.is_a_deprecated_ferret_index? + FERRET_DEPRECATION_WARNING_FN = File.join BASE_DIR, "you-have-been-warned-about-ferret-deprecation" + unless File.exist? FERRET_DEPRECATION_WARNING_FN + $stderr.puts <<EOS +Warning! Your 30-day trial period for using Sup is almost over! + +To purchase the full version of Sup, please see http://sup.rubyforge.org/. + +Just kidding. BUT! You are using an old Ferret index. The Ferret backend is +deprecated and support will be removed in the next version of Sup. + +You should convert to Xapian before that happens. + +The conversion process may take several hours. It is safe and interruptable. +You can start it at any point by typing: + + sup-convert-ferret-index + +Press enter to continue and be on your way. You won't see this message +again, just a brief reminder at shutdown. +EOS + + $stdin.gets + FileUtils.touch FERRET_DEPRECATION_WARNING_FN + end +end + begin Redwood::start Index.load + Index.start_sync_worker unless $opts[:no_threads] $die = false trap("TERM") { |x| $die = true } trap("WINCH") { |x| BufferManager.sigwinch_happened! } @@ -287,10 +314,14 @@ end when :compose ComposeMode.spawn_nicely when :poll reporting_thread("user-invoked poll") { PollManager.poll } + when :poll_unusual + if BufferManager.ask_yes_or_no "Really poll unusual sources?" + reporting_thread("user-invoked unusual poll") { PollManager.poll_unusual } + end when :recall_draft case Index.num_results_for :label => :draft when 0 bm.flash "No draft messages." when 1 @@ -327,10 +358,11 @@ Index.stop_lock_update_thread end HookManager.run "shutdown" + Index.stop_sync_worker Redwood::finish stop_cursing Redwood::Logger.remove_all_sinks! Redwood::Logger.add_sink $stderr, false debug "stopped cursing" @@ -357,21 +389,25 @@ end end $stderr.puts <<EOS ---------------------------------------------------------------- I'm very sorry. It seems that an error occurred in Sup. Please -accept my sincere apologies. If you don't mind, please send the -contents of #{BASE_DIR}/exception-log.txt and a brief report of the -circumstances to sup-talk at rubyforge dot orgs so that I might +accept my sincere apologies. Please submit the contents of +#{BASE_DIR}/exception-log.txt and a brief report of the +circumstances to http://masanjin.net/sup-bugs/ so that I might address this problem. Thank you! Sincerely, William ---------------------------------------------------------------- EOS Redwood::exceptions.each do |e, name| puts "--- #{e.class.name} from thread: #{name}" puts e.message, e.backtrace end +end + +if Index.is_a_deprecated_ferret_index? + puts "Reminder: to update your Ferret index to Xapian, run sup-convert-ferret-index." end end