]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
lei: input: warn on `L:' and `t:' use consistently master
authorEric Wong <e@80x24.org>
Sat, 9 Aug 2025 01:02:11 +0000 (01:02 +0000)
committerEric Wong <e@80x24.org>
Sat, 9 Aug 2025 07:39:22 +0000 (07:39 +0000)
When using `--in-format/-F', we need to bail out on the /\A(?:L|kw):/
check as early as possible before checking for `$urlish_scheme:' vs.
`--in-format' conflicts.  Otherwise, we'd get a confusing error
message such as: --in-format=mboxrd and `l:' conflict

lib/PublicInbox/LeiInput.pm

index f9d0d1e56f6fd3adb5c1d159c08efd69d10b696f..cc7e7aa0d09498f3d57a95f4d7198a1adeeca702 100644 (file)
@@ -353,6 +353,9 @@ sub prepare_inputs { # returns undef on error
                        # TODO: how would we detect r/w JMAP?
                        push @{$sync->{no}}, $input if $sync;
                        prepare_http_input($self, $lei, $input_path) or return;
                        # TODO: how would we detect r/w JMAP?
                        push @{$sync->{no}}, $input if $sync;
                        prepare_http_input($self, $lei, $input_path) or return;
+               } elsif ($input =~ /\A(?:L|kw):/) {
+                       return $lei->fail("Unable to handle `$input', ".
+                                       "did you mean `+$input' ?");
                } elsif ($input_path =~ s/\A([a-z0-9]+)://is) {
                        my $ifmt = lc $1;
                        if (($in_fmt // $ifmt) ne $ifmt) {
                } elsif ($input_path =~ s/\A([a-z0-9]+)://is) {
                        my $ifmt = lc $1;
                        if (($in_fmt // $ifmt) ne $ifmt) {
@@ -380,10 +383,7 @@ sub prepare_inputs { # returns undef on error
                                $may_sync and $input = "$ifmt:".
                                                $lei->abs_path($input_path);
                        } else {
                                $may_sync and $input = "$ifmt:".
                                                $lei->abs_path($input_path);
                        } else {
-                               my $m = "Unable to handle $input";
-                               $input =~ /\A(?:L|kw):/ and
-                                       $m .= ", did you mean +$input?";
-                               return $lei->fail($m);
+                               return $lei->fail("Unable to handle $input");
                        }
                } elsif ($input =~ /\.(?:eml|patch)\z/i && -f $input) {
                        lc($in_fmt//'eml') eq 'eml' or return $lei->fail(<<"");
                        }
                } elsif ($input =~ /\.(?:eml|patch)\z/i && -f $input) {
                        lc($in_fmt//'eml') eq 'eml' or return $lei->fail(<<"");