Mailing List Archive

tabular CLI output proof of concept hack
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@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.
Re: tabular CLI output proof of concept hack [ In reply to ]
> 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.

Ideally implement it in libvarnish.a and expose it in libvarnishapi,
with a way for varnishadm to specify a window size in interactive
mode. This way varnishd -d will be able to produce the plain text
output.

Dridi
_______________________________________________
varnish-dev mailing list
varnish-dev@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
Re: tabular CLI output proof of concept hack [ In reply to ]
--------
In message <CABoVN9DEjdVU1XL1QWwn8DycHSfcVoLdRB-z=H5jUeEPy4M91A@mail.gmail.com>, Dridi Boukelmoune writes:
>> 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.
>
>Ideally implement it in libvarnish.a and expose it in libvarnishapi,
>with a way for varnishadm to specify a window size in interactive
>mode. This way varnishd -d will be able to produce the plain text
>output.

I think you need to unpack that a bit before I follow ?

--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk@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.
_______________________________________________
varnish-dev mailing list
varnish-dev@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
Re: tabular CLI output proof of concept hack [ In reply to ]
On Tue, Feb 12, 2019 at 12:22 PM Poul-Henning Kamp <phk@phk.freebsd.dk> wrote:
>
> --------
> In message <CABoVN9DEjdVU1XL1QWwn8DycHSfcVoLdRB-z=H5jUeEPy4M91A@mail.gmail.com>, Dridi Boukelmoune writes:
> >> 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.
> >
> >Ideally implement it in libvarnish.a and expose it in libvarnishapi,
> >with a way for varnishadm to specify a window size in interactive
> >mode. This way varnishd -d will be able to produce the plain text
> >output.
>
> I think you need to unpack that a bit before I follow ?

My bad!

When you run varnishd -d from a terminal you may send CLI commands
from stdin and read responses from stdout. So whether it's in a VTC
log or run interactively, I think it would be harder to read the JSON
output (parsing with eyeballs=).

So my thought was that varnishd -d should stay human-friendly and
stick to plain text.

Dridi
_______________________________________________
varnish-dev mailing list
varnish-dev@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev