barcat.git
4 years agoprefer SIGINFO for statistics if available
Mischa POSLAWSKY [Thu, 12 Sep 2019 17:07:24 +0000 (19:07 +0200)]
prefer SIGINFO for statistics if available

A far more appropriate signal for non-quitting interrupts,
unfortunately only available on BSDs (bound to ctrl-T).

Keep fallback to SIGQUIT as support on linux does not seem imminent
:(http://lkml.iu.edu/hypermail/linux/kernel/1411.0/03374.html).

4 years agoshow statistics on SIGQUIT
Mischa POSLAWSKY [Thu, 12 Sep 2019 16:56:15 +0000 (18:56 +0200)]
show statistics on SIGQUIT

Misuse this signal as it's the best suited on linux being usually bound to
ctrl-\.  The same behaviour can also be seen in at least ping from iputils.
GNU dd offers similar progress on SIGUSR1, but this cannot be bound by stty.

4 years agot: multiple command arguments
Mischa POSLAWSKY [Wed, 11 Sep 2019 18:36:51 +0000 (20:36 +0200)]
t: multiple command arguments

Worked around by bundling -t and -f in t1801, but will not always be
possible.

4 years agotest for continuous progress option -t-1
Mischa POSLAWSKY [Wed, 11 Sep 2019 18:36:05 +0000 (20:36 +0200)]
test for continuous progress option -t-1

4 years agograph-format option to change bar character
Mischa POSLAWSKY [Wed, 11 Sep 2019 15:37:29 +0000 (17:37 +0200)]
graph-format option to change bar character

Set to # to revert back to v0.10 behaviour!

4 years agoonly ignore interrupt signal after input
Mischa POSLAWSKY [Wed, 11 Sep 2019 14:55:40 +0000 (16:55 +0200)]
only ignore interrupt signal after input

Assume no input is an unpiped invocation a user tries to abort by ctrl-C.

4 years agoprogress after line count with negative --interval
Mischa POSLAWSKY [Wed, 11 Sep 2019 14:51:55 +0000 (16:51 +0200)]
progress after line count with negative --interval

4 years agorespond to alarm signal regardless of interval
Mischa POSLAWSKY [Wed, 11 Sep 2019 14:42:25 +0000 (16:42 +0200)]
respond to alarm signal regardless of interval

4 years agot: report missing output as TODO
Mischa POSLAWSKY [Wed, 11 Sep 2019 12:43:15 +0000 (14:43 +0200)]
t: report missing output as TODO

TAP syntax to report expected failure.

4 years agot: replace shell scripts by pipe parameters in name
Mischa POSLAWSKY [Wed, 11 Sep 2019 12:26:22 +0000 (14:26 +0200)]
t: replace shell scripts by pipe parameters in name

4 years agotest unmarked, limits, stats, color
Mischa POSLAWSKY [Wed, 11 Sep 2019 00:42:57 +0000 (02:42 +0200)]
test unmarked, limits, stats, color

4 years agocolored values in summary stats
Mischa POSLAWSKY [Tue, 10 Sep 2019 22:00:41 +0000 (00:00 +0200)]
colored values in summary stats

4 years agoincrease value length for newline substitution
Mischa POSLAWSKY [Tue, 10 Sep 2019 19:57:14 +0000 (21:57 +0200)]
increase value length for newline substitution

Off by one since inclusion of placeholders in commit v1.02-6-g05d1a75398
(2019-09-07) [value placeholder in contents].

4 years agot: colorize results on tty output
Mischa POSLAWSKY [Tue, 10 Sep 2019 19:50:49 +0000 (21:50 +0200)]
t: colorize results on tty output

4 years agot: exit code reflects test failures
Mischa POSLAWSKY [Tue, 10 Sep 2019 19:48:22 +0000 (21:48 +0200)]
t: exit code reflects test failures

4 years agot: replace diff by comm for linewise comparison
Mischa POSLAWSKY [Tue, 10 Sep 2019 19:09:53 +0000 (21:09 +0200)]
t: replace diff by comm for linewise comparison

Prevent skipped lines, assuming matching order is retained.
Similar output otherwise after prefix replacement.

4 years agotest various formatting and options
Mischa POSLAWSKY [Tue, 10 Sep 2019 16:30:16 +0000 (18:30 +0200)]
test various formatting and options

4 years agodocumentation intro, info options
Mischa POSLAWSKY [Tue, 10 Sep 2019 01:48:57 +0000 (03:48 +0200)]
documentation intro, info options

4 years agoinline podexit code for --help, alias to -?
Mischa POSLAWSKY [Tue, 10 Sep 2019 01:48:47 +0000 (03:48 +0200)]
inline podexit code for --help, alias to -?

4 years agobrief usage documentation reformatted from pod
Mischa POSLAWSKY [Tue, 10 Sep 2019 01:11:22 +0000 (03:11 +0200)]
brief usage documentation reformatted from pod

Adjust pod text before and after rendering to better match other programs:
compact table of options described by only the first following line.

4 years agotest inputless command behaviour v1.05
Mischa POSLAWSKY [Mon, 9 Sep 2019 21:57:49 +0000 (23:57 +0200)]
test inputless command behaviour

Start t00* by testing parameter handling.

4 years agotest field selection and human readable output
Mischa POSLAWSKY [Mon, 9 Sep 2019 21:59:19 +0000 (23:59 +0200)]
test field selection and human readable output

4 years agotest commands to compare usage output, prevent regeneration
Mischa POSLAWSKY [Mon, 9 Sep 2019 21:54:20 +0000 (23:54 +0200)]
test commands to compare usage output, prevent regeneration

Any corresponding *.sh is run for more complex tests, such as partial output
comparison for --usage results.  Does not have to be generated on -G, but
any existing files can be.

4 years agoregenerate test output on regress.t -G option
Mischa POSLAWSKY [Mon, 9 Sep 2019 20:54:20 +0000 (22:54 +0200)]
regenerate test output on regress.t -G option

4 years agoparse options to regress.t
Mischa POSLAWSKY [Mon, 9 Sep 2019 21:00:12 +0000 (23:00 +0200)]
parse options to regress.t

Reserve any parameters starting with a dash.
Show usage for unknown commands ie everything.

4 years agospaces and options in test file names
Mischa POSLAWSKY [Mon, 9 Sep 2019 20:43:34 +0000 (22:43 +0200)]
spaces and options in test file names

Replace underscores by spaces to facilitate human-readable titles in sane
file names, and apply parts following a space and dash ( -*) as command
parameters to allow testing of different options.

4 years agoinitial regression test suite
Mischa POSLAWSKY [Mon, 9 Sep 2019 19:37:43 +0000 (21:37 +0200)]
initial regression test suite

Simple script to run barcat with different input from *.in, comparing to
expected *.out files and returning results in TAP format.  Execution at
t/*.t for prove compatibility.

4 years agounmodified should avoid value alignment
Mischa POSLAWSKY [Mon, 9 Sep 2019 17:19:04 +0000 (19:19 +0200)]
unmodified should avoid value alignment

4 years agocustomisable spark characters
Mischa POSLAWSKY [Mon, 9 Sep 2019 17:18:03 +0000 (19:18 +0200)]
customisable spark characters

Distributes over any number of unicode glyphs.  Hardcode interpreter for now
so -CA can be applied to easily decode arguments from UTF-8.

4 years agospark option to replace lines by single characters
Mischa POSLAWSKY [Mon, 9 Sep 2019 17:17:38 +0000 (19:17 +0200)]
spark option to replace lines by single characters

Implement "sparklines" (one-line graph) by simply substituting Unicode block
elements U+2581-2588 relative to values.  Inspired by Zach Holman's `spark`
<https://github.com/holman/spark>.

4 years agoearthquake feed example
Mischa POSLAWSKY [Mon, 9 Sep 2019 17:19:57 +0000 (19:19 +0200)]
earthquake feed example

As seen on <https://zachholman.com/spark/#cooler-usage>, but better suited
to demonstrate table markup.

4 years agodate alternative on BSD variants including OSX
Mischa POSLAWSKY [Mon, 9 Sep 2019 17:32:13 +0000 (19:32 +0200)]
date alternative on BSD variants including OSX

4 years agoreplace perl in example date parsing
Mischa POSLAWSKY [Mon, 9 Sep 2019 16:57:40 +0000 (18:57 +0200)]
replace perl in example date parsing

Time::Piece was released with perl v5.8.9 but may not be installed on
restricted systems.  Hardcoding the number of days is less flexible but
"only" relies on a GNU date supporting -d.

Furthermore, git only supports date formatting since version 2.6.0,
so prefer an equivalent cut similar to earlier year selection.

4 years agoadditional git example for date history
Mischa POSLAWSKY [Mon, 9 Sep 2019 16:56:36 +0000 (18:56 +0200)]
additional git example for date history

Simplified version of a longtime alias of mine.

4 years agoreset SIGINT after first ignoral
Mischa POSLAWSKY [Mon, 9 Sep 2019 16:51:10 +0000 (18:51 +0200)]
reset SIGINT after first ignoral

Ensure subsequent signals will break any unexpected hangs.

4 years agovoid color() shorthand to surround value
Mischa POSLAWSKY [Mon, 9 Sep 2019 16:37:39 +0000 (18:37 +0200)]
void color() shorthand to surround value

Include Term::ANSIColor::colored functionality.

4 years agocolor() function to prepare ansi escapes
Mischa POSLAWSKY [Mon, 9 Sep 2019 16:36:00 +0000 (18:36 +0200)]
color() function to prepare ansi escapes

Replace code for improved descriptiveness, identical output.  Minimal
implementation of Term::ANSIColor::color without various unwanted features.

4 years agoshorten human-readable values to 2-3 digits
Mischa POSLAWSKY [Sun, 8 Sep 2019 15:34:44 +0000 (17:34 +0200)]
shorten human-readable values to 2-3 digits

Similar to ls e.a.  Previously reserved 5 characters in order to align
decimal points, but this is pointless with mixed magnitudes.

4 years agofix sival log for negative/zero values
Mischa POSLAWSKY [Sun, 8 Sep 2019 14:44:39 +0000 (16:44 +0200)]
fix sival log for negative/zero values

4 years agooptional decimal point for human-readable integers
Mischa POSLAWSKY [Sun, 8 Sep 2019 14:39:03 +0000 (16:39 +0200)]
optional decimal point for human-readable integers

Retain input value precision.

4 years agodeclare pod encoding
Mischa POSLAWSKY [Sun, 8 Sep 2019 14:28:33 +0000 (16:28 +0200)]
declare pod encoding

Most renderers will output in the same encoding as the pod document,
which is ascii (causing an unaccented e for E<eacute>) or worse, latin1.
Best to explicitly use UTF-8 as all i/o should be.

4 years agoescape unicode character in pod
Mischa POSLAWSKY [Sun, 8 Sep 2019 14:16:41 +0000 (16:16 +0200)]
escape unicode character in pod

Avoid perldoc error:

> Non-ASCII character seen before =encoding in 'Pokémon'. Assuming UTF-8

4 years agojson example alternative without jq
Mischa POSLAWSKY [Sun, 8 Sep 2019 14:12:06 +0000 (16:12 +0200)]
json example alternative without jq

External dependency not usually installed, so describe separately.

4 years agoexplain options introduced in examples
Mischa POSLAWSKY [Sun, 8 Sep 2019 14:10:31 +0000 (16:10 +0200)]
explain options introduced in examples

4 years agoread utf-8 input in letter frequency example
Mischa POSLAWSKY [Sun, 8 Sep 2019 14:11:17 +0000 (16:11 +0200)]
read utf-8 input in letter frequency example

4 years agoreorder examples by complexity
Mischa POSLAWSKY [Sun, 8 Sep 2019 14:02:27 +0000 (16:02 +0200)]
reorder examples by complexity

Move snippets around to logically introduce different features.

4 years agodo not trim valueless contents v1.04
Mischa POSLAWSKY [Sat, 7 Sep 2019 18:49:39 +0000 (20:49 +0200)]
do not trim valueless contents

4 years agoomit empty value statistics
Mischa POSLAWSKY [Sat, 7 Sep 2019 18:28:17 +0000 (20:28 +0200)]
omit empty value statistics

4 years agoorder incoming values before interval
Mischa POSLAWSKY [Sat, 7 Sep 2019 17:32:07 +0000 (19:32 +0200)]
order incoming values before interval

If Tie::Array::Sorted is available, use it to insert input in order instead
of recalculating on every interval.  Assumes frequent refreshes of thousands
of lines, in which case it saves significantly, also slowing down less
exponentially (probably O(l) instead of O(t*l²)).

4 years agokeep ordered values, only resort on interval
Mischa POSLAWSKY [Sat, 7 Sep 2019 17:04:08 +0000 (19:04 +0200)]
keep ordered values, only resort on interval

Massive speedup per calculation.

4 years agoindicate limited results in stats
Mischa POSLAWSKY [Sat, 7 Sep 2019 16:11:46 +0000 (18:11 +0200)]
indicate limited results in stats

4 years agosilence warnings on empty input
Mischa POSLAWSKY [Sat, 7 Sep 2019 16:10:54 +0000 (18:10 +0200)]
silence warnings on empty input

4 years agoinclude total, min, avg, max in stat details
Mischa POSLAWSKY [Sat, 7 Sep 2019 16:10:03 +0000 (18:10 +0200)]
include total, min, avg, max in stat details

4 years agostat (-s) option to summarise totals at end
Mischa POSLAWSKY [Sat, 7 Sep 2019 16:05:26 +0000 (18:05 +0200)]
stat (-s) option to summarise totals at end

4 years agominor code cleanup for human formatting
Mischa POSLAWSKY [Sat, 7 Sep 2019 18:36:44 +0000 (20:36 +0200)]
minor code cleanup for human formatting

4 years agoalign human values, reserve constant length
Mischa POSLAWSKY [Sat, 7 Sep 2019 14:14:50 +0000 (16:14 +0200)]
align human values, reserve constant length

4 years agoomit source code position in regex error message
Mischa POSLAWSKY [Sat, 7 Sep 2019 14:54:18 +0000 (16:54 +0200)]
omit source code position in regex error message

4 years agocompile regular expression to -f (without /x)
Mischa POSLAWSKY [Sat, 7 Sep 2019 14:39:29 +0000 (16:39 +0200)]
compile regular expression to -f (without /x)

Reports syntax errors immediately.

4 years agosupport values with float suffixes e±N
Mischa POSLAWSKY [Sat, 7 Sep 2019 14:30:38 +0000 (16:30 +0200)]
support values with float suffixes e±N

4 years agoprepare anchor match during option parsing
Mischa POSLAWSKY [Sat, 7 Sep 2019 14:30:03 +0000 (16:30 +0200)]
prepare anchor match during option parsing

4 years agoprepare regex to match values
Mischa POSLAWSKY [Sat, 7 Sep 2019 14:17:35 +0000 (16:17 +0200)]
prepare regex to match values

Code cleanup, slight speedup.

4 years agoexponent fallback in case of unit overflow
Mischa POSLAWSKY [Sat, 7 Sep 2019 14:03:35 +0000 (16:03 +0200)]
exponent fallback in case of unit overflow

Guard against missing units.

4 years agomove human formatting code into sival() function
Mischa POSLAWSKY [Sat, 7 Sep 2019 13:49:36 +0000 (15:49 +0200)]
move human formatting code into sival() function

4 years agodecrease divider for small human numbers
Mischa POSLAWSKY [Sat, 7 Sep 2019 13:43:10 +0000 (15:43 +0200)]
decrease divider for small human numbers

4 years agohuman-readable (-H) option to abbreviate numbers
Mischa POSLAWSKY [Sat, 7 Sep 2019 13:41:57 +0000 (15:41 +0200)]
human-readable (-H) option to abbreviate numbers

Retain 2-3 significant digits and letter n-T for size.  Similar to -h in
ls, du, df, free, rsync, sort; except forgoing byte-specific powers of 1024
in favour of actually _human_ SI powers of 1000.

Common option shorthand -h conflicts with help, but capital -H has a
precedent in df --si so may be more appropriate.

4 years agocombined limit minimum-maximum
Mischa POSLAWSKY [Sat, 7 Sep 2019 03:14:43 +0000 (05:14 +0200)]
combined limit minimum-maximum

4 years agominimum limit to override start line number
Mischa POSLAWSKY [Sat, 7 Sep 2019 02:41:55 +0000 (04:41 +0200)]
minimum limit to override start line number

Internal option --hidemin or by negative -L instead of maximum.

4 years agoempty limit support (hidemax internally)
Mischa POSLAWSKY [Sat, 7 Sep 2019 02:40:01 +0000 (04:40 +0200)]
empty limit support (hidemax internally)

4 years agolimit (-L) option to stop output
Mischa POSLAWSKY [Sat, 7 Sep 2019 01:51:01 +0000 (03:51 +0200)]
limit (-L) option to stop output

4 years agohello barcat =^.^= v1.03
Mischa POSLAWSKY [Fri, 6 Sep 2019 22:22:12 +0000 (00:22 +0200)]
hello barcat =^.^=

Everybody loves cats!

4 years agorename program to barcat
Mischa POSLAWSKY [Fri, 6 Sep 2019 22:22:12 +0000 (00:22 +0200)]
rename program to barcat

English word `graph` is too common and indistinct for general distribution,
already conflicting with /usr/bin/graph from plotutils (Debian bug #61319).

4 years agograph length rounded to nearest integer
Mischa POSLAWSKY [Fri, 6 Sep 2019 22:52:43 +0000 (00:52 +0200)]
graph length rounded to nearest integer

Even distribution, and fixes unexpected overflows due to inexact float
representation after size calculation (round decimals being decremented).

4 years agovalue-length option to override $lenval
Mischa POSLAWSKY [Fri, 6 Sep 2019 23:47:10 +0000 (01:47 +0200)]
value-length option to override $lenval

4 years agofield selection by regex anchor
Mischa POSLAWSKY [Fri, 6 Sep 2019 22:58:44 +0000 (00:58 +0200)]
field selection by regex anchor

Backwards-compatible with field numbers as digits should not be number
delimiters, or could be queried like -f'(?:0)'.

4 years agoretain unsubstituted line contents
Mischa POSLAWSKY [Fri, 6 Sep 2019 23:26:20 +0000 (01:26 +0200)]
retain unsubstituted line contents

Fix length recalculation after interval.

4 years agofield (-f) option to select later values
Mischa POSLAWSKY [Fri, 6 Sep 2019 22:28:57 +0000 (00:28 +0200)]
field (-f) option to select later values

4 years agovalue placeholder in contents
Mischa POSLAWSKY [Fri, 6 Sep 2019 22:42:45 +0000 (00:42 +0200)]
value placeholder in contents

Replace original position to support later occurrences.

4 years agoignore length of valueless lines in padding
Mischa POSLAWSKY [Fri, 6 Sep 2019 22:19:08 +0000 (00:19 +0200)]
ignore length of valueless lines in padding

Excluded from graph, so do not pad other contents to align.

4 years agoshorthand -C to disable color
Mischa POSLAWSKY [Fri, 6 Sep 2019 22:18:29 +0000 (00:18 +0200)]
shorthand -C to disable color

There is precedent for capitalisation to negate, along with +c which is not
supported by Getopt::Long.

4 years agorename follow option to --interval or -t
Mischa POSLAWSKY [Fri, 6 Sep 2019 21:33:26 +0000 (23:33 +0200)]
rename follow option to --interval or -t

Initially copied f(ollow) from tail, but that letter will be better suited
for field selection, and the function is only similar.

Alternatives include -s (closer equivalent to tail, also in free --seconds),
-i as in ping --interval (best match, but should be reserved for interactive
or ignore-case), -n like watch --interval, and -v as verbose interpretation.
Settle on -t for best mnemonics; common for time(out) and found in preferred
longhand of inTerval.

4 years agoanother json example with multiple columns
Mischa POSLAWSKY [Fri, 6 Sep 2019 21:27:19 +0000 (23:27 +0200)]
another json example with multiple columns

Also found this API with the same results (and more), but needs separate
queries which is slow and unwanted so unsuitable as a fun snippet:

curl -s https://pokeapi.co/api/v2/pokemon/{1..151} |
jq -r '[.height/10,.id,.name|tostring] | join(" ")' | graph

4 years agoexamples with csv, xml, and json data
Mischa POSLAWSKY [Fri, 6 Sep 2019 21:26:39 +0000 (23:26 +0200)]
examples with csv, xml, and json data

Practical usage with most common file types.

4 years agocalculate length percentages of width v1.02
Mischa POSLAWSKY [Thu, 5 Sep 2019 21:46:21 +0000 (23:46 +0200)]
calculate length percentages of width

Shorthand to facilitate relative sizes without manual preparation.
Allow strings so trailing % can be accepted.

4 years agoenable lexical subs before perl v5.26
Mischa POSLAWSKY [Thu, 5 Sep 2019 20:09:14 +0000 (22:09 +0200)]
enable lexical subs before perl v5.26

Introduced in perl v5.18 and experimental until recently.

4 years agoskip recalculation of unprogressed data
Mischa POSLAWSKY [Thu, 5 Sep 2019 20:08:37 +0000 (22:08 +0200)]
skip recalculation of unprogressed data

4 years agostrip trailing carriage returns
Mischa POSLAWSKY [Thu, 5 Sep 2019 20:08:13 +0000 (22:08 +0200)]
strip trailing carriage returns

Support CRLF line termination regardless of system record separator,
preventing mangled output due to column returns before appended graphs.
Besides Windows files, \r is also added by unbuffer -p for some reason.

4 years agodescribe -u, rename to --unmodified
Mischa POSLAWSKY [Thu, 5 Sep 2019 21:46:57 +0000 (23:46 +0200)]
describe -u, rename to --unmodified

4 years agounclean (-u) option to keep leading whitespace
Mischa POSLAWSKY [Thu, 5 Sep 2019 20:07:49 +0000 (22:07 +0200)]
unclean (-u) option to keep leading whitespace

4 years agoman page rendering of --help pod
Mischa POSLAWSKY [Thu, 5 Sep 2019 16:48:53 +0000 (18:48 +0200)]
man page rendering of --help pod

Emulate git --help including terminal escapes.

4 years agotransition bar to visualise changed scale
Mischa POSLAWSKY [Thu, 5 Sep 2019 16:46:45 +0000 (18:46 +0200)]
transition bar to visualise changed scale

Indicate increased maximum with --follow.

4 years agoignore SIGINT so partial input is shown
Mischa POSLAWSKY [Thu, 5 Sep 2019 16:07:43 +0000 (18:07 +0200)]
ignore SIGINT so partial input is shown

Assume interrupt stops pipes and we can continue.  Subsequent signals will
then be reset so calculation can still be killed.

4 years agocolor default depends on stdout being isatty
Mischa POSLAWSKY [Thu, 5 Sep 2019 16:06:53 +0000 (18:06 +0200)]
color default depends on stdout being isatty

4 years agofollow (-f) option to output partial results
Mischa POSLAWSKY [Thu, 5 Sep 2019 15:07:05 +0000 (17:07 +0200)]
follow (-f) option to output partial results

Calculate and display on every SIGALRM, with scale and statistics upto that
point.  Named like equivalent tail -f.

4 years agoparse values while reading lines
Mischa POSLAWSKY [Thu, 5 Sep 2019 15:05:39 +0000 (17:05 +0200)]
parse values while reading lines

Manipulate input as it comes in, spreading the load and having values ready
for upcoming interrupts without a separate phase to repeat.

4 years agoseparate project repository v1.01
Mischa POSLAWSKY [Thu, 5 Sep 2019 03:16:49 +0000 (05:16 +0200)]
separate project repository

Commits moved out of home and cleaned for public distribution.
Version bump to celebrate.

4 years agoavoid drawing empty graph
Mischa POSLAWSKY [Thu, 5 Sep 2019 02:45:25 +0000 (04:45 +0200)]
avoid drawing empty graph

4 years agomarkers < > at standard deviation offsets
Mischa POSLAWSKY [Thu, 5 Sep 2019 01:54:41 +0000 (03:54 +0200)]
markers < > at standard deviation offsets

4 years agodisable markers without graph
Mischa POSLAWSKY [Wed, 4 Sep 2019 22:50:04 +0000 (00:50 +0200)]
disable markers without graph

Avoid error "Modification of non-creatable array value attempted"
trying to access unallocated positions.

4 years agocut after assumed delimiter on --trim=0
Mischa POSLAWSKY [Wed, 4 Sep 2019 22:20:35 +0000 (00:20 +0200)]
cut after assumed delimiter on --trim=0

4 years agoomit abbreviation mark on --trim=1
Mischa POSLAWSKY [Wed, 4 Sep 2019 21:55:58 +0000 (23:55 +0200)]
omit abbreviation mark on --trim=1

The first character should be whitespace or another delimiter to be kept.
Contents can be assumed cut and does not need an indicator.