$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: $!");
my @only = @{$opt->{only} // []};
# --local is enabled by default unless --only is used
# we'll allow "--only $LOCATION --local"
+ my $sto = $self->_lei_store(1);
+ my $lse = $sto->search;
if ($opt->{'local'} //= scalar(@only) ? 0 : 1) {
- my $sto = $self->_lei_store(1);
- $lxs->prepare_external($sto->search);
+ $lxs->prepare_external($lse);
}
if (@only) {
for my $loc (@only) {
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;
}
- # Consider spaces in argv to be for phrase search in Xapian.
- # In other words, the users should need only care about
- # normal shell quotes and not have to learn Xapian quoting.
- $mset_opt{qstr} = join(' ', map {;
- /\s/ ? (s/\A(\w+:)// ? qq{$1"$_"} : qq{"$_"}) : $_
- } @argv);
- $lxs->do_query($self);
+ $mset_opt{qstr} = $lse->query_argv_to_string($lse->git, \@argv);
+ _start_query($self);
}
# shell completion helper called by lei__complete