-# Copyright (C) 2019 all contributors <meta@public-inbox.org>
+# Copyright (C) 2019-2020 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# common stuff for administrative command-line tools
use Cwd 'abs_path';
use base qw(Exporter);
our @EXPORT_OK = qw(resolve_repo_dir);
-require PublicInbox::Config;
+use PublicInbox::Config;
+use PublicInbox::Inbox;
use PublicInbox::Spawn qw(popen_rd);
sub resolve_repo_dir {
sub resolve_inboxes ($;$$) {
my ($argv, $opt, $cfg) = @_;
- require PublicInbox::Inbox;
$opt ||= {};
$cfg //= eval { PublicInbox::Config->new };
if ($cfg) {
$cfg->each_inbox(sub {
my ($ibx) = @_;
- $ibx->{version} ||= 1;
my $path = abs_path($ibx->{inboxdir});
if (defined($path)) {
$dir2ibx{$path} = $ibx;
}
if ($opt->{all}) {
my @all = values %dir2ibx;
- @all = grep { $_->{version} >= $min_ver } @all;
+ @all = grep { $_->version >= $min_ver } @all;
push @ibxs, @all;
} else { # directories specified on the command-line
my $i = 0;
sub index_inbox {
my ($ibx, $im, $opt) = @_;
my $jobs = delete $opt->{jobs} if $opt;
- if (ref($ibx) && ($ibx->{version} || 1) == 2) {
+ if (ref($ibx) && $ibx->version == 2) {
eval { require PublicInbox::V2Writable };
die "v2 requirements not met: $@\n" if $@;
my $v2w = $im // eval { $ibx->importer(0) } || eval {