draw mascot cat in usage message
[barcat.git] / reformat-podusage
index cbb25cc8623a51a678078c902655719859f573bb..c40363db20fa25f4636f135acfd90344e3464fba 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/env perl
 use 5.014;
 use warnings;
+use utf8;
 use open qw( :std :utf8 );
 use re '/msx';
 
@@ -34,6 +35,16 @@ $parser->parse_string_document($pod);
 $usage =~ s/\n(?=\n\h)//msg;  # strip space between items
 $usage =~ s/^\ \ \K____/    /g;  # nbsp substitute
 
+if (open my $logo, '<', 'mascot.txt') {
+       # append logo lines to top usage lines
+       my @ll = split /\n/, readline $logo;
+       my @ul = split /\n/, $usage, @ll + 1;
+       # centered in empty space on the second (longest) line
+       my $pad = (78 - 1 + length($ul[1]) - length($ll[0])) >> 1;
+       $ul[$_] .= (' ' x ($pad - length($ul[$_]))) . $ll[$_] for 0..$#ll;
+       $usage = join "\n", @ul;
+}
+
 if ($ARGV eq '-') {
        # custom formatted minimal usage text from pod document
        print $usage;