]> git.cworth.org Git - sup/blob - bin/sup-dump
chmod a+x bin/*
[sup] / bin / sup-dump
1 #!/usr/bin/env ruby
2
3 require 'rubygems'
4 require 'trollop'
5 require "sup"
6
7 $opts = Trollop::options do
8   version "sup-dump (sup #{Redwood::VERSION})"
9   banner <<EOS
10 Dumps all message state from the sup index to standard out. You can
11 later use sup-sync --restored --restore <filename> to recover the index.
12
13 This tool is primarily useful in the event that a Ferret upgrade breaks
14 the index format. This happened, for example, at Ferret version 0.11.
15
16 Usage:
17   sup-dump > <filename>
18   sup-dump | bzip2 > <filename> # even better
19
20 No options.
21 EOS
22 end
23
24 index = Redwood::Index.new
25 index.load
26
27 (1 ... index.index.reader.max_doc).each do |i|
28   next if index.index.deleted? i
29   d = index.index[i]
30   puts [d[:message_id], "(" + d[:label] + ")"] * " "
31 end