X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FLeiQuery.pm;h=eaf91f2ec90b02647bc935788dd8aa6ff62a342c;hb=fb8b16ff2b40ecd22ebbdea0d27069749e800077;hp=d637b1ae76138974cc7cf8c47b38dcbaa3058abc;hpb=fbb7ccabbf54a4054e583dfabc4d0c4cbe2844cb;p=public-inbox.git diff --git a/lib/PublicInbox/LeiQuery.pm b/lib/PublicInbox/LeiQuery.pm index d637b1ae..eaf91f2e 100644 --- a/lib/PublicInbox/LeiQuery.pm +++ b/lib/PublicInbox/LeiQuery.pm @@ -11,10 +11,27 @@ sub prep_ext { # externals_each callback $lxs->prepare_external($loc) unless $exclude->{$loc}; } -sub qstr_add { # for --stdin +sub _start_query { + my ($self) = @_; + if (my $nwr = $self->{nwr}) { + require PublicInbox::LeiAuth; + my $auth = $self->{auth} = PublicInbox::LeiAuth->new($nwr); + my $lxs = $self->{lxs}; + $auth->auth_start($self, $lxs->can('do_query'), $lxs, $self); + } else { + $self->{lxs}->do_query($self); + } +} + +sub qstr_add { # PublicInbox::InputPipe::consume callback for --stdin my ($self) = @_; # $_[1] = $rbuf if (defined($_[1])) { - return eval { $self->{lxs}->do_query($self) } if $_[1] eq ''; + $_[1] eq '' and return eval { + my $lse = delete $self->{lse}; + $lse->query_approxidate($lse->git, + $self->{mset_opt}->{qstr}); + _start_query($self); + }; $self->{mset_opt}->{qstr} .= $_[1]; } else { $self->fail("error reading stdin: $!"); @@ -105,11 +122,12 @@ sub lei_q { no query allowed on command-line with --stdin require PublicInbox::InputPipe; + $self->{lse} = $lse; # for query_approxidate PublicInbox::InputPipe::consume($self->{0}, \&qstr_add, $self); return; } $mset_opt{qstr} = $lse->query_argv_to_string($lse->git, \@argv); - $lxs->do_query($self); + _start_query($self); } # shell completion helper called by lei__complete