2 .\" # Copyright (c) 2014, Juniper Networks, Inc.
3 .\" # All rights reserved.
4 .\" # This SOFTWARE is licensed under the LICENSE provided in the
5 .\" # ../Copyright file. By downloading, installing, copying, or
6 .\" # using the SOFTWARE, you agree to be bound by the terms of that
8 .\" # Phil Shafer, July 2014
15 .Nd emit formatted output based on format string and arguments
23 utility allows command line access to the functionality of
29 shell scripts can emit
34 using the same commands that emit text output.
36 .Bl -tag -width indent
37 .It Ic --close Ar path
38 Close tags for the given path
39 .It Ic -C | Ic --continuation
40 Indicates this output is a continuation of the previous output data
41 and should appear on the same line.
42 This is allows HTML output to be constructed correctly.
44 Set the depth for pretty printing
51 .It Ic --leading-xpath Ar path
52 Add a prefix to generated XPaths (HTML)
54 Indicate that this content is not the first in a series of sibling
55 objects, which is vital information for "JSON" output, which requires
56 a comma between such objects.
58 Open tags for the given path
59 .It Ic -p | Ic --pretty
60 Make 'pretty' output (add indent, newlines)
61 .It Ic --style Ar style
62 Generate given style (xml, json, text, html)
64 Generate text output (the default style)
66 Indicates the entire object should be placed inside a top-level
67 object wrapper, specifically when generating JSON output.
69 Display version information
71 Display warnings in text on stderr
73 Display warnings in xml on stdout
75 Wrap output in a set of containers
79 Add XPath data to HTML output
84 utility accepts a format string suitable for
86 and a set of zero or more arguments used to supply data for that string.
97 is used to emit the same data encoded in text and then in XML by
98 adding the "-p" (pretty) and "-X" (XML output) flags:
99 .Bd -literal -offset indent
100 % xo 'The {:product} is {:status}\\n' stereo "in route"
101 The stereo is in route
102 % xo -p -X 'The {:product} is {:status}\\n' stereo "in route"
103 <product>stereo</product>
104 <status>in route</status>
107 In this example, the output from a
109 command is shown in several styles:
110 .Bd -literal -offset indent
111 xo "The {k:name} weighs {:weight/%d} pounds.\\n" fish 6
114 The fish weighs 6 pounds.
123 <div class="text">The </div>
124 <div class="data" data-tag="name">fish</div>
125 <div class="text"> weighs </div>
126 <div class="data" data-tag="weight">6</div>
127 <div class="text"> pounds.</div>
133 option can be used to wrap emitted content in a
135 The path is a set of hierarchical names separated
136 by the '/' character.
137 .Bd -literal -offset indent
138 xo --wrap top/a/b/c '{:tag}' value
167 hierarchical information without the matching close and open
169 This allows a shell script to emit open tags, data, and
173 option may be used to set the
174 depth for indentation.
176 .Fl "\-leading-xpath"
178 prepend data to the XPath values used for HTML output style.
179 .Bd -literal -offset indent
182 xo --depth 2 '{tag}' value
205 library first appeared in
210 .An Phil Shafer Aq Mt phil@freebsd.org .