draw mascot cat in usage message
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 1 Nov 2022 18:41:46 +0000 (19:41 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 1 Nov 2022 18:41:46 +0000 (19:41 +0100)
barcat
mascot.txt [new file with mode: 0644]
reformat-podusage

diff --git a/barcat b/barcat
index dfe6a1018ecc8f55ba006db654366788795e43a5..da09547a389a6966d4caf2df43fb9c5c65638a3a 100755 (executable)
--- a/barcat
+++ b/barcat
@@ -352,9 +352,9 @@ sub show_exit {
 show_exit();
 
 __END__
-Usage:
-  barcat [OPTIONS] [FILES|NUMBERS]
-
+Usage:                                               /\_/\
+  barcat [OPTIONS] [FILES|NUMBERS]                  (=•.•=)
+                                                    (u   u)
 Options:
   -a, --[no-]ascii         Restrict user interface to ASCII characters
   -c, --[no-]color         Force colored output of values and bar markers
diff --git a/mascot.txt b/mascot.txt
new file mode 100644 (file)
index 0000000..0eecad7
--- /dev/null
@@ -0,0 +1,3 @@
+ /\_/\
+(=•.•=)
+(u   u)
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;