]> Sergey Matveev's repositories - public-inbox.git/blob - script/public-inbox-compact
script/*: fold $usage into $help, support `-h' instead of -?
[public-inbox.git] / script / public-inbox-compact
1 #!perl -w
2 # Copyright (C) 2018-2020 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 use strict;
5 use v5.10.1;
6 use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev);
7 my $opt = { compact => 1, -coarse_lock => 1 };
8 my $help = <<EOF; # the following should fit w/o scrolling in 80x24 term:
9 usage: public-inbox-compact INBOX_DIR
10
11   Compact Xapian DBs in an inbox
12
13 options:
14
15   --all               index all configured inboxes
16   --jobs=NUM          control parallelization
17
18 See public-inbox-compact(1) man page for full documentation.
19 EOF
20 GetOptions($opt, qw(all help|h),
21         # compact options:
22         qw(jobs|j=i quiet|q blocksize|b=s no-full|n fuller|F),
23 ) or die $help;
24 if ($opt->{help}) { print $help; exit 0 };
25
26 require PublicInbox::Admin;
27 PublicInbox::Admin::require_or_die('-index');
28 PublicInbox::Admin::progress_prepare($opt);
29
30 require PublicInbox::InboxWritable;
31 require PublicInbox::Xapcmd;
32 my @ibxs = PublicInbox::Admin::resolve_inboxes(\@ARGV, $opt);
33 unless (@ibxs) { print STDERR $help; exit 1 }
34 foreach (@ibxs) {
35         my $ibx = PublicInbox::InboxWritable->new($_);
36         PublicInbox::Xapcmd::run($ibx, 'compact', $opt);
37 }