1.\" # 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 7.\" # LICENSE. 8.\" # Phil Shafer, July 2014 9.\" 10.Dd July, 2014 11.Dt LIBXO 3 12.Os 13.Sh NAME 14.Nm xo 15.Nd emit formatted output based on format string and arguments 16.Sh SYNOPSIS 17.Nm xo 18.Op Fl options 19.Op Ar argument... 20.Sh DESCRIPTION 21The 22.Nm xo 23utility allows command line access to the functionality of 24the 25.Em libxo 26library. Using 27.Nm xo , 28shell scripts can emit 29.Em XML , 30.Em JSON , or 31.Em HTML 32using the same commands that emit text output. 33.Pp 34.Bl -tag -width "12345678901234567" 35.It Fl "-close <path>" 36Close tags for the given path 37.It Fl "-depth <num>" 38Set the depth for pretty printing 39.It Fl "-help" 40Display this help text 41.It Fl "-html OR -H" 42Generate HTML output 43.It Fl "-json OR -J" 44Generate JSON output 45.It Fl "-leading-xpath <path>" 46Add a prefix to generated XPaths (HTML) 47.It Fl "-open <path>" 48Open tags for the given path 49.It Fl "-pretty OR -p" 50Make 'pretty' output (add indent, newlines) 51.It Fl "-style <style>" 52Generate given style (xml, json, text, html) 53.It Fl "-text OR -T" 54Generate text output (the default style) 55.It Fl "-version" 56Display version information 57.It Fl "-warn OR -W" 58Display warnings in text on stderr 59.It Fl "-warn-xml" 60Display warnings in xml on stdout 61.It Fl "-wrap <path>" 62Wrap output in a set of containers 63.It Fl "-xml OR -X" 64Generate XML output 65.It Fl "-xpath" 66Add XPath data to HTML output); 67.El 68.Pp 69The 70.Nm xo 71utility accepts a format string suitable for 72.Xr xo_emit 3 73and a set of zero or more arguments used to supply data for that string. 74.Bd -literal -offset indent 75 xo "The {k:name} weighs {:weight/%d} pounds.\n" fish 6 76 77 TEXT: 78 The fish weighs 6 pounds. 79 XML: 80 <name>fish</name> 81 <weight>6</weight> 82 JSON: 83 "name": "fish", 84 "weight": 6 85 HTML: 86 <div class="line"> 87 <div class="text">The </div> 88 <div class="data" data-tag="name">fish</div> 89 <div class="text"> weighs </div> 90 <div class="data" data-tag="weight">6</div> 91 <div class="text"> pounds.</div> 92 </div> 93.Ed 94.Pp 95The 96.Fl "-wrap <path>" 97option can be used to wrap emitted content in a 98specific hierarchy. The path is a set of hierarchical names separated 99by the '/' character. 100.Bd -literal -offset indent 101 xo --wrap top/a/b/c '{:tag}' value 102 103 XML: 104 <top> 105 <a> 106 <b> 107 <c> 108 <tag>value</tag> 109 </c> 110 </b> 111 </a> 112 </top> 113 JSON: 114 "top": { 115 "a": { 116 "b": { 117 "c": { 118 "tag": "value" 119 } 120 } 121 } 122 } 123.Ed 124.Pp 125The 126.Fl "\-open <path>" 127and 128.Fl "\-close <path>" 129can be used to emit 130hierarchical information without the matching close and open 131tag. This allows a shell script to emit open tags, data, and 132then close tags. The 133.Fl \-depth 134option may be used to set the 135depth for indentation. The 136.Fl "\-leading-xpath" 137may be used to 138prepend data to the XPath values used for HTML output style. 139.Bd -literal -offset indent 140 #!/bin/sh 141 xo --open top/data 142 xo --depth 2 '{tag}' value 143 xo --close top/data 144 XML: 145 <top> 146 <data> 147 <tag>value</tag> 148 </data> 149 </top> 150 JSON: 151 "top": { 152 "data": { 153 "tag": "value" 154 } 155 } 156.Ed 157.Pp 158.Sh EXAMPLE 159.Bd -literal -offset indent 160 % xo 'The {:product} is {:status}\n' stereo "in route" 161 The stereo is in route 162 % xo -p -X 'The {:product} is {:status}\n' stereo "in route" 163 <product>stereo</product> 164 <status>in route</status> 165.Ed 166.Pp 167.Sh ADDITIONAL DOCUMENTATION 168.Pp 169Complete documentation can be found on github: 170.Bd -literal -offset indent 171http://juniper.github.io/libxo/libxo-manual.html 172.Ed 173.Pp 174libxo lives on github as: 175.Bd -literal -offset indent 176https://github.com/Juniper/libxo 177.Ed 178.Pp 179The latest release of libxo is available at: 180.Bd -literal -offset indent 181https://github.com/Juniper/libxo/releases 182.Ed 183.Sh SEE ALSO 184.Xr xo_emit 3 185.Sh HISTORY 186The 187.Fa libxo 188library was added in FreeBSD 11.0. 189.Sh AUTHOR 190Phil Shafer 191