about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiInspect.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-10-17 10:11:04 +0000
committerEric Wong <e@80x24.org>2023-10-17 20:30:05 +0000
commitcb1c4976f116ebdf94300fd474c7176e82122003 (patch)
tree405e044a4d2397acd24aedfd6f0d28bd51124a72 /lib/PublicInbox/LeiInspect.pm
parente740838a3854a45e51d8ae089a90f08c076190bd (diff)
downloadpublic-inbox-cb1c4976f116ebdf94300fd474c7176e82122003.tar.gz
We can share more code amongst stdin slurper (not streaming)
commands.  This also fixes uninitialized variable warnings when
feeding an empty stdin to these commands.
Diffstat (limited to 'lib/PublicInbox/LeiInspect.pm')
-rw-r--r--lib/PublicInbox/LeiInspect.pm12
1 files changed, 2 insertions, 10 deletions
diff --git a/lib/PublicInbox/LeiInspect.pm b/lib/PublicInbox/LeiInspect.pm
index 65c64cf2..d4ad03eb 100644
--- a/lib/PublicInbox/LeiInspect.pm
+++ b/lib/PublicInbox/LeiInspect.pm
@@ -253,20 +253,13 @@ sub inspect_start ($$) {
 
 sub do_inspect { # lei->do_env cb
         my ($lei) = @_;
-        my $str = delete $lei->{istr};
+        my $str = delete $lei->{stdin_buf};
         PublicInbox::Eml::strip_from($str);
         my $eml = PublicInbox::Eml->new(\$str);
         inspect_start($lei, [ 'blob:'.$lei->git_oid($eml)->hexdigest,
                         map { "mid:$_" } @{mids($eml)} ]);
 }
 
-sub ins_add { # InputPipe->consume callback
-        my ($lei) = @_; # $_[1] = $rbuf
-        $_[1] // return $lei->fail("error reading stdin: $!");
-        return $lei->{istr} .= $_[1] if $_[1] ne '';
-        $lei->do_env(\&do_inspect);
-}
-
 sub lei_inspect {
         my ($lei, @argv) = @_;
         $lei->{json} = ref(PublicInbox::Config::json())->new->utf8->canonical;
@@ -281,8 +274,7 @@ sub lei_inspect {
                 return $lei->fail(<<'') if @argv;
 no args allowed on command-line with --stdin
 
-                require PublicInbox::InputPipe;
-                PublicInbox::InputPipe::consume($lei->{0}, \&ins_add, $lei);
+                $lei->slurp_stdin(\&do_inspect);
         } else {
                 inspect_start($lei, \@argv);
         }