]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LEI.pm
lei mark: command for (un)setting keywords and labels
[public-inbox.git] / lib / PublicInbox / LEI.pm
index 9e3bb9b760e9cd695f33db82739273da46687a2c..91c95239fe6d0fa5993c479195afede9bfdd4f82 100644 (file)
@@ -157,9 +157,10 @@ our %CMD = ( # sorted in order of importance/use:
 'plonk' => [ '--threads|--from=IDENT',
        'exclude mail matching From: or threads from non-Message-ID searches',
        qw(stdin| threads|t from|f=s mid=s oid=s), @c_opt ],
-'mark' => [ 'MESSAGE_FLAGS...',
-       'set/unset keywords on message(s) from stdin',
-       qw(stdin| oid=s exact by-mid|mid:s), @c_opt ],
+'mark' => [ 'KEYWORDS...',
+       'set/unset keywords on message(s)',
+       qw(stdin| in-format|F=s input|i=s@ oid=s@ mid=s@), @c_opt,
+       pass_through('-kw:foo for delete') ],
 'forget' => [ '[--stdin|--oid=OID|--by-mid=MID]',
        "exclude message(s) on stdin from `q' search results",
        qw(stdin| oid=s exact by-mid|mid:s), @c_opt ],
@@ -348,7 +349,7 @@ my %CONFIG_KEYS = (
        'leistore.dir' => 'top-level storage location',
 );
 
-my @WQ_KEYS = qw(lxs l2m imp mrr cnv p2q); # internal workers
+my @WQ_KEYS = qw(lxs l2m imp mrr cnv p2q mark); # internal workers
 
 # pronounced "exit": x_it(1 << 8) => exit(1); x_it(13) => SIGPIPE
 sub x_it ($$) {
@@ -419,23 +420,6 @@ sub fail ($$;$) {
        undef;
 }
 
-sub check_input_format ($;$) {
-       my ($self, $files) = @_;
-       my $opt_key = 'in-format';
-       my $fmt = $self->{opt}->{$opt_key};
-       if (!$fmt) {
-               my $err = $files ? "regular file(s):\n@$files" : '--stdin';
-               return fail($self, "--$opt_key unset for $err");
-       }
-       require PublicInbox::MboxLock if $files;
-       require PublicInbox::MboxReader;
-       return 1 if $fmt eq 'eml';
-       # XXX: should this handle {gz,bz2,xz}? that's currently in LeiToMail
-       PublicInbox::MboxReader->can($fmt) or
-               return fail($self, "--$opt_key=$fmt unrecognized");
-       1;
-}
-
 sub out ($;@) {
        my $self = shift;
        return if print { $self->{1} // return } @_; # likely
@@ -477,7 +461,7 @@ sub lei_atfork_child {
                open STDERR, '+>&='.fileno($self->{2}) or warn "open $!";
                delete $self->{0};
        }
-       delete @$self{qw(cnv)};
+       delete @$self{qw(cnv mark imp)};
        for (delete @$self{qw(3 old_1 au_done)}) {
                close($_) if defined($_);
        }
@@ -498,12 +482,13 @@ sub lei_atfork_child {
 sub workers_start {
        my ($lei, $wq, $ident, $jobs, $ops) = @_;
        $ops = {
-               '!' => [ $lei->can('fail_handler'), $lei ],
-               '|' => [ $lei->can('sigpipe_handler'), $lei ],
-               'x_it' => [ $lei->can('x_it'), $lei ],
-               'child_error' => [ $lei->can('child_error'), $lei ],
-               %$ops
+               '!' => [ \&fail_handler, $lei ],
+               '|' => [ \&sigpipe_handler, $lei ],
+               'x_it' => [ \&x_it, $lei ],
+               'child_error' => [ \&child_error, $lei ],
+               ($ops ? %$ops : ()),
        };
+       $ops->{''} //= [ \&dclose, $lei ];
        require PublicInbox::PktOp;
        ($lei->{pkt_op_c}, $lei->{pkt_op_p}) = PublicInbox::PktOp->pair($ops);
        $wq->wq_workers_start($ident, $jobs, $lei->oldset, { lei => $lei });
@@ -706,10 +691,6 @@ sub lei_show {
        my ($self, @argv) = @_;
 }
 
-sub lei_mark {
-       my ($self, @argv) = @_;
-}
-
 sub _config {
        my ($self, @argv) = @_;
        my %env = (%{$self->{env}}, GIT_CONFIG => undef);