]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei <rediff|rm|tag>: stdin implies `-F eml'
authorEric Wong <e@80x24.org>
Tue, 2 Nov 2021 18:14:45 +0000 (18:14 +0000)
committerEric Wong <e@80x24.org>
Tue, 2 Nov 2021 19:07:06 +0000 (19:07 +0000)
These commands are usually run on a single message, so saving
the user the trouble of typing `-F eml' on the command-line
seems reasonable.  I don't think commands like "index" and
"import" will be too useful for single messages, though.

lib/PublicInbox/LeiRediff.pm
lib/PublicInbox/LeiRm.pm
lib/PublicInbox/LeiTag.pm

index f0521bcc6b623ae54963809754a9e0ae9f67aeca..c312d90fbfe90eff46ff7da552e38b13fc1b2383 100644 (file)
@@ -256,7 +256,7 @@ sub lei_rediff {
        ($lei->{opt}->{drq} && !$lei->{opt}->{verbose}) and
                $lei->{opt}->{quiet} //= 1;
        $lei->_lei_store(1)->write_prepare($lei);
-       $lei->{opt}->{'in-format'} //= 'eml';
+       $lei->{opt}->{'in-format'} //= 'eml' if $lei->{opt}->{stdin};
        # maybe it's a non-email (code) blob from a coderepo
        my $git_dirs = $lei->{opt}->{'git-dir'} //= [];
        if ($lei->{opt}->{cwd} // 1) {
index 62423ac9828e7c2ec851f36de0161c08cd2fbaf3..00b124852e7443fb76eda91aed14d26c7c64d3ca 100644 (file)
@@ -16,7 +16,7 @@ sub input_eml_cb { # used by PublicInbox::LeiInput::input_fh
 sub lei_rm {
        my ($lei, @inputs) = @_;
        $lei->_lei_store(1)->write_prepare($lei);
-       $lei->{opt}->{'in-format'} //= 'eml';
+       $lei->{opt}->{'in-format'} //= 'eml' if $lei->{opt}->{stdin};
        my $self = bless {}, __PACKAGE__;
        $self->prepare_inputs($lei, \@inputs) or return;
        $lei->{-err_type} = 'non-fatal';
index 2dc59f7023cac20d158a90880b8aa7d22c6620c8..8ce96a102a8013b8280bf608ed2b5311d37cf546 100644 (file)
@@ -27,8 +27,8 @@ sub pmdir_cb { # called via wq_io_do from LeiPmdir->each_mdir_fn
 
 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);