X-Git-Url: http://git.shiar.nl/barcat.git/blobdiff_plain/2c67b83a73065c44448ba562ddc83403e97abd8d..b7992da312c627399c0363b59b3c00df380aee1d:/barcat diff --git a/barcat b/barcat index a4ed12f..a443942 100755 --- a/barcat +++ b/barcat @@ -6,7 +6,7 @@ use List::Util qw( min max sum ); use open qw( :std :utf8 ); use experimental qw( lexical_subs ); -our $VERSION = '1.04'; +our $VERSION = '1.05'; use Getopt::Long '2.33', qw( :config gnu_getopt ); sub podexit { @@ -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