header option to prepend value scale
[barcat.git] / barcat
diff --git a/barcat b/barcat
index 1bcda801779e9a4028b07f5005b5217b5d5120e8..268c993db3a76b223e04114c6506489b727e5c25 100755 (executable)
--- 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.05';
+our $VERSION = '1.06';
 
 use Getopt::Long '2.33', qw( :config gnu_getopt );
 my %opt;
@@ -42,6 +42,7 @@ GetOptions(\%opt,
                        " (range expected)\n"
                );
        },
+       'header!',
        'markers|m=s',
        'graph-format=s' => sub {
                $opt{'graph-format'} = substr $_[1], 0, 1;
@@ -53,6 +54,10 @@ GetOptions(\%opt,
        'signal-stat=s',
        'unmodified|u!',
        'width|w=i',
+       'version' => sub {
+               say "barcat version $VERSION";
+               exit;
+       },
        'usage|h' => sub {
                local $/;
                my $pod = readline *DATA;
@@ -188,6 +193,8 @@ sub sival {
        );
 }
 
+say sprintf '%*s-+%*s-+', $lenval, $minval, $size * ($maxval - $minval) - 3, $maxval if $opt{header};
+
 while ($nr <= $#lines) {
        $nr >= $opt{hidemax} and last if defined $opt{hidemax};
        my $val = $values[$nr];
@@ -290,6 +297,10 @@ A string can indicate the starting position of a value
 or capture the numbers itself,
 for example I<-f'(\d+)'> for the first digits anywhere.
 
+=item --header
+
+Prepend a chart axis with minimum and maximum values labeled.
+
 =item -H, --human-readable
 
 Format values using SI unit prefixes,