svn commit: r284198 - head/bin/ls

Adrian Chadd adrian at freebsd.org
Sat Jun 13 17:57:47 UTC 2015


On 13 June 2015 at 10:06, Marcel Moolenaar <marcel at xcllnt.net> wrote:
>
>> On Jun 13, 2015, at 12:35 PM, Adrian Chadd <adrian at freebsd.org> wrote:
>>
>> Hi,
>>
>> I think we're at the point now where it's worth doing that
>> re-evaluation. I don't think it's worth backing everything out; just
>> whether the current approach of overriding printing the way it's done
>> is the right way.
>>
>> So, how about that happens nowish before more things are converted?
>
> What do you suggest we do instead?

So a lot of these things are table driven. Having manual printing for
tabular data is plain stupid.

The libbsdstat library for doing basic statistics output with "now"
and "time series" is what I'm playing with right now. It's only used
by sam's wifi utilities, but I'm going to try and extend it for other
utilities too (like netstat, vmstat, etc style output.)

That way what's expressed in code is organised as such:

* a bit of code fetches statistics
* a bit of code sets up what the name of each field is, and what the units are
* a bit of code handles any odd corner cases with data representations
* libbsdstat takes care of recording the samples into the time-series
or 'now' section, figuring out which fields need to be printed in
which order, what the formatting is, etc.
* .. I'm extending it to print out json for its table outputs versus
just plain text.

Having arbitrary formatting, arbitrary printing, random places where
statistics are fetched, etc is actually the terrible problem that we
could do better, without losing our minds by overcomplicating it with
C++, templating, grammars, etc - and ending up with what look like
five layers of nested java classes that do "Setter(ToString(Getter())"
in layers.



-adrian


More information about the svn-src-head mailing list