XML Output: libxo - provide single API to output TXT, XML, JSON and HTML
Garance A Drosehn
drosih at rpi.edu
Thu Jul 31 16:41:07 UTC 2014
On 31 Jul 2014, at 5:18, Phil Shafer wrote:
> "Simon J. Gerraty" writes:
>> w(1) sizes those strings based on its expectation of the width of the
>> tty. That can obviously be fixed/improved - but involves exposing
>> knowledge of the out format (or at least that it isn't TXT) to the
>> application.
>
> libxo allows the field description to carry two distinct format
> descriptors, one for text/html and one for xml/json. The latter
> defaults to the former:
>
> xo_emit(" {:words/%7ju/%ju}", twordct);
>
> For "w", this is does the right thing; in text mode, the command
> string is truncated:
Ah, that's helpful.
What if there's something you want to print out for xml/json but
*not* for plain-text? (it's easy to imagine some commands might
print out more values when they are not constrained by an 80-char
width).
Also, given that machine-readable outputs might change over time,
is there the idea of including a version-number with the output
for each command?
I hope it doesn't seem like I'm just complaining about the work
everyone else is doing (both this and the GSOC project). Please
note that I've attempted to do this a few times myself, and I haven't
been happy with any of *my* attempts either!
--
Garance Alistair Drosehn = drosih at rpi.edu
Senior Systems Programmer or gad at FreeBSD.org
Rensselaer Polytechnic Institute; Troy, NY; USA
More information about the freebsd-arch
mailing list