-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 $usage = "public-inbox-index INBOX_DIR";
+use PublicInbox::Admin;
+PublicInbox::Admin::require_or_die('-index');
+use PublicInbox::Xapcmd;
+
+my $compact_opt;
+my $opt = { quiet => -1, compact => 0, maxsize => undef };
+GetOptions($opt, qw(verbose|v+ reindex compact|c+ jobs|j=i prune
+ indexlevel|L=s maxsize|max-size=s))
+ or die "bad command-line args\n$usage";
+die "--jobs must be positive\n" if defined $opt->{jobs} && $opt->{jobs} <= 0;
+
+if ($opt->{compact}) {
+ require PublicInbox::Xapcmd;
+ PublicInbox::Xapcmd::check_compact();
+ $compact_opt = { -coarse_lock => 1, compact => 1 };