git.shiar.nl
/
barcat.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
minimum limit to override start line number
[barcat.git]
/
barcat
diff --git
a/barcat
b/barcat
index 2901486fa5b155092681b72bd531970e2a19dc46..c4244d4e61d5e99d4c80d6432387782f27d4296d 100755
(executable)
--- a/
barcat
+++ b/
barcat
@@
-29,6
+29,10
@@
GetOptions(\%opt,
$opt{trim} = $optval;
},
'value-length=i',
$opt{trim} = $optval;
},
'value-length=i',
+ 'hidemin=i',
+ 'hidemax|limit|L=i' => sub {
+ $opt{$_[1] < 0 ? 'hidemin' : 'hidemax'} = abs $_[1];
+ },
'markers|m=s',
'unmodified|u!',
'width|w=i',
'markers|m=s',
'unmodified|u!',
'width|w=i',
@@
-75,15
+79,16
@@
$SIG{INT} = 'DEFAULT';
sub show_lines {
sub show_lines {
-state $nr = 0;
+state $nr =
$opt{hidemin} ? $opt{hidemin} - 1 :
0;
@lines and @lines > $nr or return;
my @order = sort { $b <=> $a } grep { length } @values;
@lines and @lines > $nr or return;
my @order = sort { $b <=> $a } grep { length } @values;
-my $maxval = $order[0];
+my $maxval = $o
pt{hidemax} ? max @values[0 .. $opt{hidemax} - 1] : $o
rder[0];
my $minval = min $order[-1], 0;
my $lenval = $opt{'value-length'} // max map { length } @order;
my $len = defined $opt{trim} && $opt{trim} <= 0 ? -$opt{trim} + 1 :
my $minval = min $order[-1], 0;
my $lenval = $opt{'value-length'} // max map { length } @order;
my $len = defined $opt{trim} && $opt{trim} <= 0 ? -$opt{trim} + 1 :
- max map { length $values[$_] && length $lines[$_] } 0 .. $#lines; # left padding
+ max map { length $values[$_] && length $lines[$_] }
+ 0 .. min $#lines, $opt{hidemax} || (); # left padding
my $size = ($maxval - $minval) &&
($opt{width} - $lenval - $len) / ($maxval - $minval); # bar multiplication
my $size = ($maxval - $minval) &&
($opt{width} - $lenval - $len) / ($maxval - $minval); # bar multiplication
@@
-112,6
+117,7
@@
if ($opt{markers} // 1 and $size > 0) {
}
while ($nr <= $#lines) {
}
while ($nr <= $#lines) {
+ $nr >= $opt{hidemax} and last if $opt{hidemax};
my $val = $values[$nr];
if (length $val) {
my $color = !$opt{color} ? 0 :
my $val = $values[$nr];
if (length $val) {
my $color = !$opt{color} ? 0 :
@@
-125,6
+131,7
@@
while ($nr <= $#lines) {
printf '%-*s', $len + length($val), $line;
print $barmark[$_] // '-' for 1 .. $size && (($values[$nr] || 0) - $minval) * $size + .5;
say '';
printf '%-*s', $len + length($val), $line;
print $barmark[$_] // '-' for 1 .. $size && (($values[$nr] || 0) - $minval) * $size + .5;
say '';
+
$nr++;
}
$nr++;
}
@@
-183,6
+190,12
@@
unless C<--length=0>.
Prepend a dash (i.e. make negative) to enforce padding
regardless of encountered contents.
Prepend a dash (i.e. make negative) to enforce padding
regardless of encountered contents.
+=item -L, --limit=[-]<count>
+
+Stop output after a number of lines.
+All input is still counted and analyzed for statistics,
+but disregarded for padding and bar size.
+
=item -m, --markers=
Statistical positions to indicate on bars.
=item -m, --markers=
Statistical positions to indicate on bars.
@@
-289,7
+302,7
@@
Git statistics, such commit count by year:
Or the most frequent authors:
Or the most frequent authors:
- git shortlog -sn | barcat
| head -
3
+ git shortlog -sn | barcat
-L
3
Latency history:
Latency history: