From: Mischa POSLAWSKY Date: Tue, 10 Sep 2019 01:11:22 +0000 (+0200) Subject: brief usage documentation reformatted from pod X-Git-Tag: v1.06~25 X-Git-Url: http://git.shiar.nl/barcat.git/commitdiff_plain/b7992da312c627399c0363b59b3c00df380aee1d brief usage documentation reformatted from pod Adjust pod text before and after rendering to better match other programs: compact table of options described by only the first following line. --- diff --git a/barcat b/barcat index 978a222..a443942 100755 --- a/barcat +++ b/barcat @@ -53,7 +53,22 @@ GetOptions(\%opt, 'stat|s!', 'unmodified|u!', 'width|w=i', - 'usage|h' => sub { podexit() }, + 'usage|h' => sub { + local $/; + my $pod = readline *DATA; + $pod =~ s/^=over\K/ 22/m; # indent options list + $pod =~ s/^=item \N*\n\n\N*\n\K(?:(?:^=over.*?^=back\n)?(?!=)\N*\n)*/\n/msg; + + require Pod::Usage; + my $parser = Pod::Usage->new; + $parser->select('SYNOPSIS', 'OPTIONS'); + $parser->output_string(\my $contents); + $parser->parse_string_document($pod); + + $contents =~ s/\n(?=\n\h)//msg; # strip space between items + print $contents; + exit; + }, 'help' => sub { podexit(-verbose => 2) }, ) or exit 64; # EX_USAGE