]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LEI.pm
lei-rm: add man page, support LeiInput args
[public-inbox.git] / lib / PublicInbox / LEI.pm
index 8b6c1d36f179e8969510ed3f4cf4e85c2c61cb1d..3dce02363286597b6106a965277b3395024978f5 100644 (file)
@@ -226,7 +226,7 @@ our %CMD = ( # sorted in order of importance/use:
 'rm' => [ '--stdin|LOCATION...',
        'remove a message from the index and prevent reindexing',
        'stdin|', # /|\z/ must be first for lone dash
-       @c_opt ],
+       qw(in-format|F=s lock=s@), @c_opt ],
 '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 ],
@@ -279,8 +279,8 @@ our %CMD = ( # sorted in order of importance/use:
                'git-config(1) wrapper for '._config_path($_[0]);
        }, qw(config-file|system|global|file|f=s), # for conflict detection
         qw(c=s@ C=s@), pass_through('git config') ],
-'inspect' => [ 'ITEMS...', 'inspect lei/store and/or local external',
-       qw(pretty ascii dir=s), @c_opt ],
+'inspect' => [ 'ITEMS...|--stdin', 'inspect lei/store and/or local external',
+       qw(stdin| pretty ascii dir=s), @c_opt ],
 
 'init' => [ '[DIRNAME]', sub {
        "initialize storage, default: ".store_path($_[0]);
@@ -605,16 +605,19 @@ sub incr {
        $self->{counters}->{$field} += $nr;
 }
 
+sub pkt_ops {
+       my ($lei, $ops) = @_;
+       $ops->{'!'} = [ \&fail_handler, $lei ];
+       $ops->{'|'} = [ \&sigpipe_handler, $lei ];
+       $ops->{x_it} = [ \&x_it, $lei ];
+       $ops->{child_error} = [ \&child_error, $lei ];
+       $ops->{incr} = [ \&incr, $lei ];
+       $ops;
+}
+
 sub workers_start {
        my ($lei, $wq, $jobs, $ops, $flds) = @_;
-       $ops = {
-               '!' => [ \&fail_handler, $lei ],
-               '|' => [ \&sigpipe_handler, $lei ],
-               'x_it' => [ \&x_it, $lei ],
-               'child_error' => [ \&child_error, $lei ],
-               'incr' => [ \&incr, $lei ],
-               ($ops ? %$ops : ()),
-       };
+       $ops = pkt_ops($lei, { ($ops ? %$ops : ()) });
        $ops->{''} //= [ $wq->can('_lei_wq_eof') || \&wq_eof, $lei ];
        my $end = $lei->pkt_op_pair;
        my $ident = $wq->{-wq_ident} // "lei-$lei->{cmd} worker";
@@ -1330,6 +1333,7 @@ sub lazy_start {
        open STDOUT, '>&STDIN' or die "redirect stdout failed: $!";
        # $daemon pipe to `lei' closed, main loop begins:
        PublicInbox::DS->EventLoop;
+       dump_and_clear_log();
        exit($exit_code // 0);
 }