On Tue, 30 Oct 2018 10:34:45 -0600
David Ahern <[email protected]> wrote:
> A more flexible approach is to use format strings to allow users to
> customize the output order and whitespace as well. So for ss and your
> column list (winging it here):
>
> netid = %N
> state = %S
> recv Q = %Qr
> send Q = %Qs
> local address = %Al
> lport port = %Pl
> remote address = %Ar
> remote port = %Pr
> process data = %p
> ...
>
> then a format string could be: "%S %Qr %Qs %Al:%Pl %Ar:%Pr %p\n"
I like the idea indeed, but I see two issues with ss:
- the current column abstraction is rather lightweight, things are
already buffered in the defined column order so we don't have to jump
back and forth in the buffer while rendering. Doing that needs some
extra care to avoid a performance hit, but it's probably doable, I
can put that on my to-do list
- how would you model automatic spacing in a format string? Should we
support width specifiers? Disable automatic spacing if a format
string is given? It might even make sense to allow partial automatic
spacing with a special character in the format string, that is:
"%S.%Qr.%Qs %Al:%Pl %Ar:%Pr %p\n"
would mean "align everything to the right, distribute remaining
whitespace between %S, %Qr and %Qs". But it looks rather complicated
at a glance.
--
Stefano