+
+ if ($opt->{stdin}) {
+ return $self->fail(<<'') if @argv;
+no query allowed on command-line with --stdin
+
+ require PublicInbox::InputPipe;
+ PublicInbox::InputPipe::consume($self->{0}, \&qstr_add, $self);
+ return;
+ }
+ chomp(@argv) and $self->qerr("# trailing `\\n' removed");
+ $mset_opt{q_raw} = [ @argv ]; # copy
+ $mset_opt{qstr} =
+ $self->{lse}->query_argv_to_string($self->{lse}->git, \@argv);
+ _start_query($self);
+}
+
+# shell completion helper called by lei__complete
+sub _complete_q {
+ my ($self, @argv) = @_;
+ my @cur;
+ my $cb = $self->lazy_cb(qw(forget-external _complete_));
+ while (@argv) {
+ if ($argv[-1] =~ /\A(?:-I|(?:--(?:include|exclude|only)))\z/) {
+ my @c = $cb->($self, @cur);
+ # try basename match:
+ if (scalar(@cur) == 1 && index($cur[0], '/') < 0) {
+ my $all = $self->externals_each;
+ my %bn;
+ for my $loc (keys %$all) {
+ my $bn = (split(m!/!, $loc))[-1];
+ ++$bn{$bn};
+ }
+ push @c, grep {
+ $bn{$_} == 1 && /\A\Q$cur[0]/
+ } keys %bn;
+ }
+ return @c if @c;
+ }
+ unshift(@cur, pop @argv);
+ }
+ ();