tabular CLI output proof of concept hack

Poul-Henning Kamp phk at
Mon Feb 11 22:59:23 UTC 2019

While looking at #2896 it bothered me how much code we spend on
text-processing the CLI output.

Since we now have -j for machine-readable output, it would make
sense to make the non-j output more human-friendly, and avoid some
of all that text-processing at the same time.

I threw together the attached proof-of-concept hack, which adds
a central function to figure out how wide the columns of tabular
output should be, and to reformat it thusly.

The idea is that the CLI code, in this case vcl.list sticks
some ASCII control-chars in the vsb to mark the columns, which then
autosize once all the output is ready, rather than have all the
"lets set this column width to 28 ? 45 ? 51?" guesswork.

In the hack I have also added column headers for nicer output
so that it looks like this:

	Status Readiness Ref Name        
	====== ========= === ====         
	active auto/warm 1   vcl1          

(Ignore the amount of space/padding etc, that's for later)

I kind of like it.

But I am also seriously wondering if we should go even further and
have varnishd *only* produce JSON output, and leave the render-for-humans
aspect to varnishapi or even varnishadm.

Comments welcome...

Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: _.patch
Type: text/x-diff
Size: 4522 bytes
Desc: _.patch
URL: <>

More information about the varnish-dev mailing list