From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id ACB6A1F8C9 for ; Thu, 1 Jul 2021 11:31:33 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/2] lei inspect: support automatic pager in output Date: Thu, 1 Jul 2021 11:31:32 +0000 Message-Id: <20210701113133.30648-2-e@80x24.org> In-Reply-To: <20210701113133.30648-1-e@80x24.org> References: <20210701113133.30648-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: All commands which output non-trivial amounts of data to the terminal should support this. --- lib/PublicInbox/LeiInspect.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/LeiInspect.pm b/lib/PublicInbox/LeiInspect.pm index 30714764..9a7900c7 100644 --- a/lib/PublicInbox/LeiInspect.pm +++ b/lib/PublicInbox/LeiInspect.pm @@ -155,9 +155,6 @@ sub inspect1 ($$$) { sub lei_inspect { my ($lei, @argv) = @_; - $lei->{1}->autoflush(0); - my $multi = scalar(@argv) > 1; - $lei->out('[') if $multi; $lei->{json} = ref(PublicInbox::Config::json())->new->utf8->canonical; $lei->{lse} = ($lei->{opt}->{external} // 1) ? do { my $sto = $lei->_lei_store; @@ -166,6 +163,10 @@ sub lei_inspect { if ($lei->{opt}->{pretty} || -t $lei->{1}) { $lei->{json}->pretty(1)->indent(2); } + $lei->start_pager if -t $lei->{1}; + $lei->{1}->autoflush(0); + my $multi = scalar(@argv) > 1; + $lei->out('[') if $multi; while (defined(my $x = shift @argv)) { inspect1($lei, $x, scalar(@argv)) or return; }