lib/PublicInbox/LeiQuery.pm | 9 ++++++++- lib/PublicInbox/LeiXSearch.pm | 2 +- t/lei.t | 3 +++ diff --git a/lib/PublicInbox/LeiQuery.pm b/lib/PublicInbox/LeiQuery.pm index 7713902b0e94e72b89d88851f4ff8cc93bb4ca7a..953d1fc22076f4ac77069d1c0769bf7a2107e34d 100644 --- a/lib/PublicInbox/LeiQuery.pm +++ b/lib/PublicInbox/LeiQuery.pm @@ -26,7 +26,14 @@ if ($opt->{external} //= 1) { my $cb = $lxs->can('prepare_external'); my $ne = $self->_externals_each($cb, $lxs); $opt->{remote} //= $ne == $lxs->remotes; - delete($lxs->{remotes}) if !$opt->{remote}; + if ($opt->{'local'}) { + delete($lxs->{remotes}) if !$opt->{remote}; + } else { + delete($lxs->{locals}); + } + } + unless ($lxs->locals || $lxs->remotes) { + return $self->fail('no local or remote inboxes to search'); } my $xj = $lxs->concurrency($opt); my $ovv = PublicInbox::LeiOverview->new($self) or return; diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index c396c59734589b0b21bd4932da7a4688d9d3c750..0417db245d9ddb0a5e2995d53aba695e7a108d58 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -311,7 +311,7 @@ if ($lei->{opt}->{thread}) { for my $ibxish (locals($self)) { $self->wq_do('query_thread_mset', $io, $lei, $ibxish); } - } else { + } elsif (locals($self)) { $self->wq_do('query_mset', $io, $lei); } my $i = 0; diff --git a/t/lei.t b/t/lei.t index 60ca75c5da8084be83078b5679ac6176d3e0ed3f..3fd1d1fe5c1d3acc2ad1b1e104c3100888bbf5e6 100644 --- a/t/lei.t +++ b/t/lei.t @@ -277,6 +277,9 @@ is_deeply(\@res, [], "clobber w/o --augment $sfx"); } ok(!$lei->('q', '-o', "$home/mbox", 's:nope'), 'fails if mbox format unspecified'); + ok(!$lei->(qw(q --no-local s:see)), '--no-local'); + is($? >> 8, 1, 'proper exit code'); + like($err, qr/no local or remote.+? to search/, 'no inbox'); my %e = ( TEST_LEI_EXTERNAL_HTTPS => 'https://public-inbox.org/meta/', TEST_LEI_EXTERNAL_ONION => $onions[int(rand(scalar(@onions)))],