X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FLeiTag.pm;h=8ce96a102a8013b8280bf608ed2b5311d37cf546;hb=refs%2Fheads%2Fmaster;hp=c4f5ecffb575168044b216139874e2d8a14c5e2d;hpb=7b7939d47b336fb7d8c4387858e620dbc218bb1e;p=public-inbox.git diff --git a/lib/PublicInbox/LeiTag.pm b/lib/PublicInbox/LeiTag.pm index c4f5ecff..8ce96a10 100644 --- a/lib/PublicInbox/LeiTag.pm +++ b/lib/PublicInbox/LeiTag.pm @@ -12,34 +12,23 @@ sub input_eml_cb { # used by PublicInbox::LeiInput::input_fh my ($self, $eml) = @_; if (my $xoids = $self->{lse}->xoids_for($eml) // # tries LeiMailSync $self->{lei}->{ale}->xoids_for($eml)) { - $self->{lei}->{sto}->ipc_do('update_xvmd', $xoids, $eml, + $self->{lei}->{sto}->wq_do('update_xvmd', $xoids, $eml, $self->{vmd_mod}); } else { ++$self->{unimported}; } } -sub input_mbox_cb { - my ($eml, $self) = @_; - $eml->header_set($_) for (qw(X-Status Status)); - input_eml_cb($self, $eml); -} - sub pmdir_cb { # called via wq_io_do from LeiPmdir->each_mdir_fn my ($self, $f) = @_; my $eml = eml_from_path($f) or return; input_eml_cb($self, $eml); } -sub input_net_cb { # imap_each, nntp_each cb - my ($url, $uid, $kw, $eml, $self) = @_; - input_eml_cb($self, $eml); -} - sub lei_tag { # the "lei tag" method my ($lei, @argv) = @_; - my $sto = $lei->_lei_store(1); - $sto->write_prepare($lei); + $lei->{opt}->{'in-format'} //= 'eml' if $lei->{opt}->{stdin}; + my $sto = $lei->_lei_store(1)->write_prepare($lei); my $self = bless {}, __PACKAGE__; $lei->ale; # refresh and prepare my $vmd_mod = $self->vmd_mod_extract(\@argv); @@ -48,13 +37,8 @@ sub lei_tag { # the "lei tag" method $self->prepare_inputs($lei, \@argv) or return; grep(defined, @$vmd_mod{qw(+kw +L -L -kw)}) or return $lei->fail('no keywords or labels specified'); - my $ops = {}; - $lei->{auth}->op_merge($ops, $self) if $lei->{auth}; - (my $op_c, $ops) = $lei->workers_start($self, 1, $ops); - $lei->{wq1} = $self; $lei->{-err_type} = 'non-fatal'; - net_merge_all_done($self) unless $lei->{auth}; - $lei->wait_wq_events($op_c, $ops); + $lei->wq1_start($self); } sub note_unimported { @@ -74,7 +58,7 @@ sub ipc_atfork_child { # Workaround bash word-splitting s to ['kw', ':', 'keyword' ...] # Maybe there's a better way to go about this in # contrib/completion/lei-completion.bash -sub _complete_mark_common ($) { +sub _complete_tag_common ($) { my ($argv) = @_; # Workaround bash word-splitting URLs to ['https', ':', '//' ...] # Maybe there's a better way to go about this in @@ -104,16 +88,18 @@ sub _complete_mark_common ($) { # FIXME: same problems as _complete_forget_external and similar sub _complete_tag { my ($self, @argv) = @_; + require PublicInbox::LeiImport; + my @in = PublicInbox::LeiImport::_complete_import(@_); my @L = eval { $self->_lei_store->search->all_terms('L') }; - my @all = ((map { ("+kw:$_", "-kw:$_") } @PublicInbox::LeiInput::KW), + my @kwL = ((map { ("+kw:$_", "-kw:$_") } @PublicInbox::LeiInput::KW), (map { ("+L:$_", "-L:$_") } @L)); - return @all if !@argv; - my ($cur, $re) = _complete_mark_common(\@argv); - map { + my ($cur, $re) = _complete_tag_common(\@argv); + my @m = map { # only return the part specified on the CLI # don't duplicate if already 100% completed /\A$re(\Q$cur\E.*)/ ? ($cur eq $1 ? () : $1) : (); - } grep(/$re\Q$cur/, @all); + } grep(/$re\Q$cur/, @kwL); + (@in, (@m ? @m : @kwL)); } no warnings 'once'; # the following works even when LeiAuth is lazy-loaded