Date: Thu, 31 Jul 2014 05:18:27 -0400 From: Phil Shafer <phil@juniper.net> To: "Simon J. Gerraty" <sjg@juniper.net> Cc: arch@freebsd.org, marcel@freebsd.org, Garance A Drosehn <drosih@rpi.edu> Subject: Re: XML Output: libxo - provide single API to output TXT, XML, JSON and HTML Message-ID: <201407310918.s6V9IRj5092988@idle.juniper.net> In-Reply-To: <20140731034031.B2FC5580A2@chaos.jnpr.net>
next in thread | previous in thread | raw e-mail | index | archive | help
"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:
5:08AM up 27 days, 12:22, 11 user%s, load averages: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE WHAT
phil pts/1 76.182.32.73 05Jul14 - /usr/bin/perl /u/phil/bin/plum (
...
In XML mode, the command is not truncated.
<uptime-information>
<time-of-day> 5:09AM</time-of-day>
<uptime seconds="2377336">27 days</uptime>
<uptime>12:22</uptime>
<users>11</users>
<load-average-1>0.00</load-average-1>
<load-average-5>0.00</load-average-5>
<load-average-15>0.00</load-average-15>
<user-table>
<user-entry>
<user>phil</user>
<tty>pts/1</tty>
<from>76.182.32.73</from>
<login-time>05Jul14</login-time>
<idle> 1</idle>
<command>/usr/bin/perl /u/phil/bin/plum (perl5.12.4)</command>
</user-entry>
...
(Yes, I'm likely the only plum user left in the wild.)
Thanks,
Phil
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201407310918.s6V9IRj5092988>
