Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Aug 2014 09:11:27 -0400
From:      Phil Shafer <phil@juniper.net>
To:        Stefan Esser <se@freebsd.org>
Cc:        Marcel Moolenaar <marcel@freebsd.org>, John-Mark Gurney <jmg@funkthat.com>, Alfred Perlstein <bright@mu.org>, "Simon J. Gerraty" <sjg@juniper.net>, "arch@freebsd.org" <arch@freebsd.org>, Poul-Henning Kamp <phk@phk.freebsd.dk>, Konstantin Belousov <kostikbel@gmail.com>, Marcel Moolenaar <marcel@xcllnt.net>
Subject:   Re: XML Output: libxo - provide single API to output TXT, XML, JSON and HTML
Message-ID:  <201408181311.s7IDBRtD018629@idle.juniper.net>
In-Reply-To: <53F1A311.4080707@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Stefan Esser writes:
>Is it possible to introduce a "xo" command which takes a command
>line as an argument (in the same way as e.g. "time").  A sample
>usage could be "xo ls -s", which should invoke "ls -l" with its
>output converted to XML (and "xo -json ls -l" could produce JSON
>output).

I've implemented the "--libxo" option, in a function called
xo_parse_args(), that it called before getopt* and processes and
removes libxo options.  See the example on:

http://juniper.github.io/libxo/libxo-manual.html

FWIW, there's an "xo" command packaged with libxo that perform
similar to the printf(1) command:

% xo --wrap top/data 'My {:pet} is {:age} years old\n' dog 2
My dog is 2 years old
% xo --xml --pretty --wrap top/data 'My {:pet} is {:age} years old\n' dog 2
<top>
  <data>
    <pet>dog</pet>
    <age>2</age>
  </data>
</top>

Thanks,
 Phil



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408181311.s7IDBRtD018629>