graph-format option to change bar character
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 11 Sep 2019 15:37:29 +0000 (17:37 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 12 Sep 2019 15:48:11 +0000 (17:48 +0200)
Set to # to revert back to v0.10 behaviour!

barcat
t/t0002-usage_-h_|wc_-l.out

diff --git a/barcat b/barcat
index 2f73fa5ab2c59e3e8be6ce6b0b57fd235641587a..bdfde47398a22d678ef8e2b02bd01a2afd74193f 100755 (executable)
--- a/barcat
+++ b/barcat
@@ -43,6 +43,9 @@ GetOptions(\%opt,
                );
        },
        'markers|m=s',
+       'graph-format=s' => sub {
+               $opt{'graph-format'} = substr $_[1], 0, 1;
+       },
        'spark:s' => sub {
                $opt{spark} = [split //, $_[1] || '⎽▁▂▃▄▅▆▇█'];
        },
@@ -75,6 +78,7 @@ GetOptions(\%opt,
 
 $opt{width} ||= $ENV{COLUMNS} || 80;
 $opt{color} //= -t *STDOUT;  # enable on tty
+$opt{'graph-format'} //= '-';
 $opt{trim}   *= $opt{width} / 100 if $opt{trimpct};
 $opt{units}   = [split //, ' kMGTPEZYyzafpnμm'] if $opt{'human-readable'};
 $opt{anchor} //= qr/\A/;
@@ -205,7 +209,7 @@ while ($nr <= $#lines) {
        }
        my $line = $lines[$nr] =~ s/\n/$val/r;
        printf '%-*s', $len + length($val), $line;
-       print $barmark[$_] // '-' for 1 .. $size && (($values[$nr] || 0) - $minval) * $size + .5;
+       print $barmark[$_] // $opt{'graph-format'} for 1 .. $size && (($values[$nr] || 0) - $minval) * $size + .5;
        say '';
 }
 continue {
@@ -308,6 +312,11 @@ Stop output after a number of lines.
 All input is still counted and analyzed for statistics,
 but disregarded for padding and bar size.
 
+=item --graph-format=<character>
+
+Glyph to repeat for the graph line.
+Defaults to a dash C<->.
+
 =item -m, --markers=
 
 Statistical positions to indicate on bars.
index 6f4247a6255c99f420d1df558d68745592862ff7..9902f17848a8974ab57d57999b74a63198fe6e23 100644 (file)
@@ -1 +1 @@
-26
+28