From 30fb51a784dd9314c6776f18b7189b197be12df3 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Wed, 18 Sep 2019 23:17:07 +0200 Subject: [PATCH] header option to prepend value scale Single top line to indicate minimum and maximum values, similar to scale in common-lisp vspark . --- barcat | 7 +++++++ t/t0002-usage_-h_|wc_-l.out | 2 +- ...echnicolor_-cs.in => t1901-technicolor_-cs_--header.in} | 0 ...hnicolor_-cs.out => t1901-technicolor_-cs_--header.out} | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) rename t/{t1901-technicolor_-cs.in => t1901-technicolor_-cs_--header.in} (100%) rename t/{t1901-technicolor_-cs.out => t1901-technicolor_-cs_--header.out} (96%) diff --git a/barcat b/barcat index db0aefa..268c993 100755 --- a/barcat +++ b/barcat @@ -42,6 +42,7 @@ GetOptions(\%opt, " (range expected)\n" ); }, + 'header!', 'markers|m=s', 'graph-format=s' => sub { $opt{'graph-format'} = substr $_[1], 0, 1; @@ -192,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]; @@ -294,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, diff --git a/t/t0002-usage_-h_|wc_-l.out b/t/t0002-usage_-h_|wc_-l.out index f04c001..e85087a 100644 --- a/t/t0002-usage_-h_|wc_-l.out +++ b/t/t0002-usage_-h_|wc_-l.out @@ -1 +1 @@ -29 +31 diff --git a/t/t1901-technicolor_-cs.in b/t/t1901-technicolor_-cs_--header.in similarity index 100% rename from t/t1901-technicolor_-cs.in rename to t/t1901-technicolor_-cs_--header.in diff --git a/t/t1901-technicolor_-cs.out b/t/t1901-technicolor_-cs_--header.out similarity index 96% rename from t/t1901-technicolor_-cs.out rename to t/t1901-technicolor_-cs_--header.out index 2048557..e1d4a41 100644 --- a/t/t1901-technicolor_-cs.out +++ b/t/t1901-technicolor_-cs_--header.out @@ -1,3 +1,4 @@ + -3-+ 2-+  -3  -2.449 --  -2 ---- -- 2.30.0