-use warnings;
-my $usage = "public-inbox-index GIT_DIR";
-use PublicInbox::Config;
-eval { require PublicInbox::SearchIdx };
-if ($@) {
- print STDERR "Search::Xapian required for $0\n";
- exit 1;
-}
-my @dirs;
-
-sub resolve_git_dir {
- my ($cd) = @_;
- my @cmd = qw(git rev-parse --git-dir);
- my $cmd = join(' ', @cmd);
- my $pid = open my $fh, '-|';
- defined $pid or die "forking $cmd failed: $!\n";
- if ($pid == 0) {
- if (defined $cd) {
- chdir $cd or die "chdir $cd failed: $!\n";
- }
- exec @cmd;
- die "Failed to exec $cmd: $!\n";
- } else {
- my $dir = eval {
- local $/;
- <$fh>;
- };
- close $fh or die "error in $cmd: $!\n";
- chomp $dir;
- return $cd if ($dir eq '.' && defined $cd);
- $dir;
- }
-}
+use v5.10.1;
+use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev);
+my $help = <<EOF; # the following should fit w/o scrolling in 80x24 term:
+usage: public-inbox-index [options] INBOX_DIR
+
+ Create and update search indices
+
+options:
+
+ --no-fsync speed up indexing, risk corruption on power outage
+ -L LEVEL `basic', `medium', or `full' (default: full)
+ --all index all configured inboxes
+ --compact | -c run public-inbox-compact(1) after indexing
+ --sequential-shard index Xapian shards sequentially for slow storage
+ --jobs=NUM set or disable parallelization (NUM=0)
+ --batch-size=BYTES flush changes to OS after a given number of bytes
+ --max-size=BYTES do not index messages larger than the given size
+ --reindex index previously indexed data (if upgrading)
+ --rethread regenerate thread IDs (if upgrading, use sparingly)
+ --prune prune git storage on discontiguous history
+ --verbose | -v increase verbosity (may be repeated)