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
40 Set the depth for pretty printing
47 .It Ic --leading-xpath Ar path
48 Add a prefix to generated XPaths (HTML)
50 Open tags for the given path
51 .It Ic -p | Ic --pretty
52 Make 'pretty' output (add indent, newlines)
53 .It Ic --style Ar style
54 Generate given style (xml, json, text, html)
56 Generate text output (the default style)
58 Display version information
60 Display warnings in text on stderr
62 Display warnings in xml on stdout
64 Wrap output in a set of containers
68 Add XPath data to HTML output
73 utility accepts a format string suitable for
75 and a set of zero or more arguments used to supply data for that string.
86 is used to emit the same data encoded in text and then in XML by
87 adding the "-p" (pretty) and "-X" (XML output) flags:
88 .Bd -literal -offset indent
89 % xo 'The {:product} is {:status}\\n' stereo "in route"
90 The stereo is in route
91 % xo -p -X 'The {:product} is {:status}\\n' stereo "in route"
92 <product>stereo</product>
93 <status>in route</status>
96 In this example, the output from a
98 command is shown in several styles:
99 .Bd -literal -offset indent
100 xo "The {k:name} weighs {:weight/%d} pounds.\\n" fish 6
103 The fish weighs 6 pounds.
112 <div class="text">The </div>
113 <div class="data" data-tag="name">fish</div>
114 <div class="text"> weighs </div>
115 <div class="data" data-tag="weight">6</div>
116 <div class="text"> pounds.</div>
122 option can be used to wrap emitted content in a
124 The path is a set of hierarchical names separated
125 by the '/' character.
126 .Bd -literal -offset indent
127 xo --wrap top/a/b/c '{:tag}' value
156 hierarchical information without the matching close and open
158 This allows a shell script to emit open tags, data, and
162 option may be used to set the
163 depth for indentation.
165 .Fl "\-leading-xpath"
167 prepend data to the XPath values used for HTML output style.
168 .Bd -literal -offset indent
171 xo --depth 2 '{tag}' value
194 library first appeared in
199 .An Phil Shafer Aq Mt phil@freebsd.org .