]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei mail-diff: support more inputs, split newlines
authorEric Wong <e@80x24.org>
Tue, 26 Oct 2021 21:18:05 +0000 (21:18 +0000)
committerEric Wong <e@80x24.org>
Wed, 27 Oct 2021 05:22:42 +0000 (05:22 +0000)
Support --in-format like the rest of LeiInput users, and don't
default to .eml if a per-input format was specified.  In any
case, I saved a bunch of messages from mutt which uses mboxcl2.

We'll also split newlines for diff, since it's a pain to read
diffs with escaped "\n" characters in them.

lib/PublicInbox/LEI.pm
lib/PublicInbox/LeiMailDiff.pm

index f9d24f29c87d0dfc82056c8b767b64ca05c8a46b..96f7c5e315a9d4b8b182953cd0a6269db880ca66 100644 (file)
@@ -202,7 +202,7 @@ our %CMD = ( # sorted in order of importance/use:
 
 'mail-diff' => [ '--stdin|LOCATION...', 'diff the contents of emails',
        'stdin|', # /|\z/ must be first for lone dash
 
 'mail-diff' => [ '--stdin|LOCATION...', 'diff the contents of emails',
        'stdin|', # /|\z/ must be first for lone dash
-       qw(verbose|v+ color:s no-color raw-header),
+       qw(verbose|v+ in-format|F=s color:s no-color raw-header),
        @diff_opt, @net_opt, @c_opt ],
 
 'add-external' => [ 'LOCATION',
        @diff_opt, @net_opt, @c_opt ],
 
 'add-external' => [ 'LOCATION',
index 4f3a4608d8e0beceafda3830b9fff41ffbae6b4d..b21a0c366fd68aa6c8198a99e7bbf5b7f9ea8cca 100644 (file)
@@ -76,7 +76,7 @@ sub input_eml_cb { # used by PublicInbox::LeiInput::input_fh
 
 sub lei_mail_diff {
        my ($lei, @argv) = @_;
 
 sub lei_mail_diff {
        my ($lei, @argv) = @_;
-       $lei->{opt}->{'in-format'} //= 'eml';
+       $lei->{opt}->{'in-format'} //= 'eml' if !grep(/\A[a-z0-9]+:/i, @argv);
        my $self = bless {}, __PACKAGE__;
        $self->prepare_inputs($lei, \@argv) or return;
        my $isatty = -t $lei->{1};
        my $self = bless {}, __PACKAGE__;
        $self->prepare_inputs($lei, \@argv) or return;
        my $isatty = -t $lei->{1};
@@ -94,7 +94,7 @@ sub lei_mail_diff {
 no warnings 'once';
 *net_merge_all_done = \&PublicInbox::LeiInput::input_only_net_merge_all_done;
 
 no warnings 'once';
 *net_merge_all_done = \&PublicInbox::LeiInput::input_only_net_merge_all_done;
 
-package PublicInbox::ContentDigestDbg;
+package PublicInbox::ContentDigestDbg; # cf. PublicInbox::ContentDigest
 use strict;
 use v5.10.1;
 use Data::Dumper;
 use strict;
 use v5.10.1;
 use Data::Dumper;
@@ -103,7 +103,7 @@ sub new { bless { dig => Digest::SHA->new(256), fh => $_[1] }, __PACKAGE__ }
 
 sub add {
        $_[0]->{dig}->add($_[1]);
 
 sub add {
        $_[0]->{dig}->add($_[1]);
-       print { $_[0]->{fh} } Dumper($_[1]) or die "print $!";
+       print { $_[0]->{fh} } Dumper([split(/^/sm, $_[1])]) or die "print $!";
 }
 
 sub hexdigest { $_[0]->{dig}->hexdigest; }
 }
 
 sub hexdigest { $_[0]->{dig}->hexdigest; }