7 The `xo` utility allows command line access to the functionality of
8 the libxo library. Using `xo`, shell scripts can emit XML, JSON, and
9 HTML using the same commands that emit text output.
11 The style of output can be selected using a specific option: "-X" for
12 XML, "-J" for JSON, "-H" for HTML, or "-T" for TEXT, which is the
13 default. The "--style <style>" option can also be used. The standard
14 set of "--libxo" options are available (see :ref:`options`), as well
15 as the `LIBXO_OPTIONS`_ environment variable.
17 .. _`LIBXO_OPTIONS`: :ref:`libxo-options`
19 The `xo` utility accepts a format string suitable for `xo_emit` and
20 a set of zero or more arguments used to supply data for that string::
22 xo "The {k:name} weighs {:weight/%d} pounds.\n" fish 6
25 The fish weighs 6 pounds.
34 <div class="text">The </div>
35 <div class="data" data-tag="name">fish</div>
36 <div class="text"> weighs </div>
37 <div class="data" data-tag="weight">6</div>
38 <div class="text"> pounds.</div>
41 The `--wrap $path` option can be used to wrap emitted content in a
42 specific hierarchy. The path is a set of hierarchical names separated
43 by the '/' character::
45 xo --wrap top/a/b/c '{:tag}' value
68 The `--open $path` and `--close $path` can be used to emit
69 hierarchical information without the matching close and open
70 tag. This allows a shell script to emit open tags, data, and
71 then close tags. The `--depth` option may be used to set the
72 depth for indentation. The `--leading-xpath` may be used to
73 prepend data to the XPath values used for HTML output style::
78 xo --depth 2 '{tag}' value
98 Usage: xo [options] format [fields]
99 --close <path> Close tags for the given path
100 --depth <num> Set the depth for pretty printing
101 --help Display this help text
102 --html OR -H Generate HTML output
103 --json OR -J Generate JSON output
104 --leading-xpath <path> Add a prefix to generated XPaths (HTML)
105 --open <path> Open tags for the given path
106 --pretty OR -p Make 'pretty' output (add indent, newlines)
107 --style <style> Generate given style (xml, json, text, html)
108 --text OR -T Generate text output (the default style)
109 --version Display version information
110 --warn OR -W Display warnings in text on stderr
111 --warn-xml Display warnings in xml on stdout
112 --wrap <path> Wrap output in a set of containers
113 --xml OR -X Generate XML output
114 --xpath Add XPath data to HTML output);
121 % xo 'The {:product} is {:status}\n' stereo "in route"
122 The stereo is in route
123 % ./xo/xo -p -X 'The {:product} is {:status}\n' stereo "in route"
124 <product>stereo</product>
125 <status>in route</status>