From: Mischa POSLAWSKY Date: Mon, 14 Oct 2019 23:06:59 +0000 (+0200) Subject: optional width of sparkline lines X-Git-Tag: v1.07~21 X-Git-Url: http://git.shiar.net/barcat.git/commitdiff_plain/b0d6f88a7fbd1e478b0b1892c5832229a99e252f optional width of sparkline lines Output newlines after specified number of records. Keep current single line by default. --- diff --git a/barcat b/barcat index 424bec2..3bc7ca0 100755 --- a/barcat +++ b/barcat @@ -101,7 +101,7 @@ GetOptions(\%opt, }, ) or exit 64; # EX_USAGE -$opt{width} ||= $ENV{COLUMNS} || qx(tput cols) || 80; +$opt{width} ||= $ENV{COLUMNS} || qx(tput cols) || 80 unless $opt{spark}; $opt{color} //= -t *STDOUT; # enable on tty $opt{'graph-format'} //= '-'; $opt{trim} *= $opt{width} / 100 if $opt{trimpct}; @@ -154,6 +154,10 @@ while (defined ($_ = $opt{input} ? shift @{ $opt{input} } : readline)) { and $. % $opt{interval} == 0; } +if ($opt{'zero-missing'}) { + push @values, (0) x 10; +} + $SIG{INT} = 'DEFAULT'; sub color { @@ -243,6 +247,7 @@ while ($nr <= $#lines) { $opt{palette}->[ $rel * ($#{$opt{palette}} - 1) + 1 ]; if ($opt{spark}) { + say '' if $opt{width} and $nr and $nr % $opt{width} == 0; print color($color), $opt{spark}->[ !$val ? 0 : # blank $val == $order[0] ? -1 : # max