lib/PublicInbox/LeiQuery.pm | 5 ++++- lib/PublicInbox/LeiToMail.pm | 12 +++++------- diff --git a/lib/PublicInbox/LeiQuery.pm b/lib/PublicInbox/LeiQuery.pm index 0435a5163137a4f0693bf7374bf544041aa0ace0..eb7b98d416fa20e2c323cad6d7d7eda2453c8a89 100644 --- a/lib/PublicInbox/LeiQuery.pm +++ b/lib/PublicInbox/LeiQuery.pm @@ -1,7 +1,8 @@ # Copyright (C) 2021 all contributors # License: AGPL-3.0+ -# handles lei commands +# handles "lei q" command and provides internals for +# several other sub-commands (up, lcat, ...) package PublicInbox::LeiQuery; use strict; use v5.10.1; @@ -130,6 +131,8 @@ # the default } else { die "unrecognized --sort=$sort\n"; } + $opt->{save} and return + $self->fail('--save and --sort are incompatible'); } $self->{mset_opt} = \%mset_opt; diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm index 997ce5993c897c653b76426c366bee4b5d67b7f6..5b5caee76a1908761ae507c0fd00318ea6500ca6 100644 --- a/lib/PublicInbox/LeiToMail.pm +++ b/lib/PublicInbox/LeiToMail.pm @@ -384,6 +384,7 @@ my ($cls, $lei) = @_; my $fmt = $lei->{ovv}->{fmt}; my $dst = $lei->{ovv}->{dst}; my $self = bless {}, $cls; + my @conflict; if ($fmt eq 'maildir') { require PublicInbox::MdirReader; $self->{base_type} = 'maildir'; @@ -412,13 +413,14 @@ } elsif ($fmt eq 'text') { require PublicInbox::LeiViewText; $lei->{lvt} = PublicInbox::LeiViewText->new($lei); $self->{base_type} = 'text'; + @conflict = qw(mua save); } elsif ($fmt eq 'v2') { die "--dedupe=oid and v2 are incompatible\n" if ($lei->{opt}->{dedupe}//'') eq 'oid'; $self->{base_type} = 'v2'; $lei->{opt}->{save} = \1; - die "--mua incompatible with v2\n" if $lei->{opt}->{mua}; $dst = $lei->{ovv}->{dst} = $lei->abs_path($dst); + @conflict = qw(mua sort); } else { die "bad mail --format=$fmt\n"; } @@ -426,12 +428,8 @@ if ($self->{base_type} =~ /\A(?:text|mbox)\z/) { (-d $dst || (-e _ && !-w _)) and die "$dst exists and is not a writable file\n"; } - if ($self->{base_type} eq 'text') { - my @err = map { - defined($lei->{opt}->{$_}) ? "--$_" : (); - } (qw(mua save)); - die "@err incompatible with $fmt\n" if @err; - } + my @err = map { defined($lei->{opt}->{$_}) ? "--$_" : () } @conflict; + die "@err incompatible with $fmt\n" if @err; $self->{dst} = $dst; $lei->{dedupe} = $lei->{lss} // do { my $dd_cls = 'PublicInbox::'.