]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiLcat.pm
lei: more eval guards for die on failure
[public-inbox.git] / lib / PublicInbox / LeiLcat.pm
index 0902c213deee71a070c434e7c2948075ef444b75..191f6f244857221d0086db1b0548d64ed35b2c8a 100644 (file)
@@ -124,18 +124,15 @@ could not extract Message-ID from $x
 
 sub _stdin { # PublicInbox::InputPipe::consume callback for --stdin
        my ($lei) = @_; # $_[1] = $rbuf
-       if (defined($_[1])) {
-               $_[1] eq '' and return eval {
-                       $lei->fchdir or return;
-                       my @argv = split(/\s+/, $lei->{mset_opt}->{qstr});
-                       $lei->{mset_opt}->{qstr} = extract_all($lei, @argv)
-                               or return;
-                       $lei->_start_query;
-               };
-               $lei->{mset_opt}->{qstr} .= $_[1];
-       } else {
-               $lei->fail("error reading stdin: $!");
-       }
+       $_[1] // return $lei->fail("error reading stdin: $!");
+       return $lei->{mset_opt}->{qstr} .= $_[1] if $_[1] ne '';
+       eval {
+               $lei->fchdir;
+               my @argv = split(/\s+/, $lei->{mset_opt}->{qstr});
+               $lei->{mset_opt}->{qstr} = extract_all($lei, @argv) or return;
+               $lei->_start_query;
+       };
+       $lei->fail($@) if $@;
 }
 
 sub lei_lcat {
@@ -144,9 +141,8 @@ sub lei_lcat {
        $lei->ale->refresh_externals($lxs, $lei);
        $lei->_lei_store(1);
        my $opt = $lei->{opt};
-       my %mset_opt = map { $_ => $opt->{$_} } qw(threads limit offset);
+       my %mset_opt;
        $mset_opt{asc} = $opt->{'reverse'} ? 1 : 0;
-       $mset_opt{limit} //= 10000;
        $opt->{sort} //= 'relevance';
        $mset_opt{relevance} = 1;
        $lei->{mset_opt} = \%mset_opt;
@@ -164,10 +160,9 @@ no args allowed on command-line with --stdin
 }
 
 sub _complete_lcat {
-       my ($lei, @argv) = @_;
-       my $lms = $lei->lms or return;
-       my $match_cb = $lei->complete_url_prepare(\@argv);
-       map { $match_cb->($_) } $lms->folders;
+       require PublicInbox::LeiRefreshMailSync;
+       PublicInbox::LeiRefreshMailSync::_complete_refresh_mail_sync(@_);
+       # TODO: message-ids?, blobs? could get expensive...
 }
 
 1;