#!/usr/bin/env ruby require 'rubygems' require 'trollop' require "sup"; Redwood::check_library_version_against "0.10.1" $opts = Trollop::options do version "sup-dump (sup #{Redwood::VERSION})" banner <<EOS Dumps all message state from the sup index to standard out. You can later use sup-sync --restored --restore <filename> to recover the index. This tool is primarily useful in the event that a Ferret upgrade breaks the index format. This happened, for example, at Ferret version 0.11. Usage: sup-dump > <filename> sup-dump | bzip2 > <filename> # even better Options: EOS opt :index, "Use this index type ('auto' for autodetect)", :default => "auto" end index = Redwood::Index.init $opts[:index] Redwood::SourceManager.init index.load index.each_message :load_spam => true, :load_deleted => true, :load_killed => true do |m| puts "#{m.id} (#{m.labels.to_a.sort_by { |l| l.to_s } * ' '})" end