1983afe33SPhil Shafer 2983afe33SPhil Shafer.. index:: --libxo 3983afe33SPhil Shafer.. index:: Options 4983afe33SPhil Shafer 5983afe33SPhil Shafer.. _options: 6983afe33SPhil Shafer 7983afe33SPhil ShaferCommand-line Arguments 8983afe33SPhil Shafer====================== 9983afe33SPhil Shafer 10983afe33SPhil Shaferlibxo uses command line options to trigger rendering behavior. There 11983afe33SPhil Shaferare multiple conventions for passing options, all using the 12983afe33SPhil Shafer"`--libxo`" option:: 13983afe33SPhil Shafer 14983afe33SPhil Shafer --libxo <options> 15983afe33SPhil Shafer --libxo=<options> 16983afe33SPhil Shafer --libxo:<brief-options> 17983afe33SPhil Shafer 18983afe33SPhil ShaferThe *brief-options* is a series of single letter abbrevations, where 19983afe33SPhil Shaferthe *options* is a comma-separated list of words. Both provide access 20983afe33SPhil Shaferto identical functionality. The following invocations are all 21983afe33SPhil Shaferidentical in outcome:: 22983afe33SPhil Shafer 23983afe33SPhil Shafer my-app --libxo warn,pretty arg1 24983afe33SPhil Shafer my-app --libxo=warn,pretty arg1 25983afe33SPhil Shafer my-app --libxo:WP arg1 26983afe33SPhil Shafer 27983afe33SPhil ShaferPrograms using libxo are expecting to call the xo_parse_args function 28983afe33SPhil Shaferto parse these arguments. See :ref:`xo_parse_args` for details. 29983afe33SPhil Shafer 30983afe33SPhil ShaferOption Keywords 31983afe33SPhil Shafer--------------- 32983afe33SPhil Shafer 33983afe33SPhil ShaferOptions is a comma-separated list of tokens that correspond to output 34983afe33SPhil Shaferstyles, flags, or features: 35983afe33SPhil Shafer 36983afe33SPhil Shafer =============== ======================================================= 37983afe33SPhil Shafer Token Action 38983afe33SPhil Shafer =============== ======================================================= 39983afe33SPhil Shafer color Enable colors/effects for display styles (TEXT, HTML) 40983afe33SPhil Shafer colors=xxxx Adjust color output values 41983afe33SPhil Shafer dtrt Enable "Do The Right Thing" mode 42983afe33SPhil Shafer flush Flush after every libxo function call 43983afe33SPhil Shafer flush-line Flush after every line (line-buffered) 44983afe33SPhil Shafer html Emit HTML output 45983afe33SPhil Shafer indent=xx Set the indentation level 46983afe33SPhil Shafer info Add info attributes (HTML) 47983afe33SPhil Shafer json Emit JSON output 48983afe33SPhil Shafer keys Emit the key attribute for keys (XML) 49983afe33SPhil Shafer log-gettext Log (via stderr) each gettext(3) string lookup 50983afe33SPhil Shafer log-syslog Log (via stderr) each syslog message (via xo_syslog) 51983afe33SPhil Shafer no-humanize Ignore the {h:} modifier (TEXT, HTML) 52983afe33SPhil Shafer no-locale Do not initialize the locale setting 53983afe33SPhil Shafer no-retain Prevent retaining formatting information 54983afe33SPhil Shafer no-top Do not emit a top set of braces (JSON) 55983afe33SPhil Shafer not-first Pretend the 1st output item was not 1st (JSON) 56983afe33SPhil Shafer pretty Emit pretty-printed output 57983afe33SPhil Shafer retain Force retaining formatting information 58983afe33SPhil Shafer text Emit TEXT output 59983afe33SPhil Shafer underscores Replace XML-friendly "-"s with JSON friendly "_"s 60983afe33SPhil Shafer units Add the 'units' (XML) or 'data-units (HTML) attribute 61983afe33SPhil Shafer warn Emit warnings when libxo detects bad calls 62983afe33SPhil Shafer warn-xml Emit warnings in XML 63983afe33SPhil Shafer xml Emit XML output 64983afe33SPhil Shafer xpath Add XPath expressions (HTML) 65983afe33SPhil Shafer =============== ======================================================= 66983afe33SPhil Shafer 67983afe33SPhil ShaferMost of these option are simple and direct, but some require 68983afe33SPhil Shaferadditional details: 69983afe33SPhil Shafer 70983afe33SPhil Shafer- "colors" is described in :ref:`color-mapping`. 71983afe33SPhil Shafer- "flush-line" performs line buffering, even when the output is not 72983afe33SPhil Shafer directed to a TTY device. 73983afe33SPhil Shafer- "info" generates additional data for HTML, encoded in attributes 74983afe33SPhil Shafer using names that state with "data-". 75983afe33SPhil Shafer- "keys" adds a "key" attribute for XML output to indicate that a leaf 76983afe33SPhil Shafer is an identifier for the list member. 77983afe33SPhil Shafer- "no-humanize" avoids "humanizing" numeric output (see 78983afe33SPhil Shafer :ref:`humanize-modifier` for details). 79983afe33SPhil Shafer- "no-locale" instructs libxo to avoid translating output to the 80983afe33SPhil Shafer current locale. 81983afe33SPhil Shafer- "no-retain" disables the ability of libxo to internally retain 82983afe33SPhil Shafer "compiled" information about formatting strings (see :ref:`retain` 83983afe33SPhil Shafer for details). 84983afe33SPhil Shafer- "underscores" can be used with JSON output to change XML-friendly 85983afe33SPhil Shafer names with dashes into JSON-friendly name with underscores. 86983afe33SPhil Shafer- "warn" allows libxo to emit warnings on stderr when application code 87983afe33SPhil Shafer make incorrect calls. 88983afe33SPhil Shafer- "warn-xml" causes those warnings to be placed in XML inside the 89983afe33SPhil Shafer output. 90983afe33SPhil Shafer 91983afe33SPhil ShaferBrief Options 92983afe33SPhil Shafer------------- 93983afe33SPhil Shafer 94983afe33SPhil ShaferThe brief options are simple single-letter aliases to the normal 95983afe33SPhil Shaferkeywords, as detailed below: 96983afe33SPhil Shafer 97983afe33SPhil Shafer ======== ============================================= 98983afe33SPhil Shafer Option Action 99983afe33SPhil Shafer ======== ============================================= 100983afe33SPhil Shafer c Enable color/effects for TEXT/HTML 101983afe33SPhil Shafer F Force line-buffered flushing 102983afe33SPhil Shafer H Enable HTML output (XO_STYLE_HTML) 103983afe33SPhil Shafer I Enable info output (XOF_INFO) 104983afe33SPhil Shafer i<num> Indent by <number> 105983afe33SPhil Shafer J Enable JSON output (XO_STYLE_JSON) 106983afe33SPhil Shafer k Add keys to XPATH expressions in HTML 107983afe33SPhil Shafer n Disable humanization (TEXT, HTML) 108983afe33SPhil Shafer P Enable pretty-printed output (XOF_PRETTY) 109983afe33SPhil Shafer T Enable text output (XO_STYLE_TEXT) 110983afe33SPhil Shafer U Add units to HTML output 111983afe33SPhil Shafer u Change "-"s to "_"s in element names (JSON) 112983afe33SPhil Shafer W Enable warnings (XOF_WARN) 113983afe33SPhil Shafer X Enable XML output (XO_STYLE_XML) 114983afe33SPhil Shafer x Enable XPath data (XOF_XPATH) 115983afe33SPhil Shafer ======== ============================================= 116983afe33SPhil Shafer 117983afe33SPhil Shafer.. index:: Colors 118983afe33SPhil Shafer 119983afe33SPhil Shafer.. _color-mapping: 120983afe33SPhil Shafer 121983afe33SPhil ShaferColor Mapping 122983afe33SPhil Shafer------------- 123983afe33SPhil Shafer 124983afe33SPhil ShaferThe "colors" option takes a value that is a set of mappings from the 125983afe33SPhil Shaferpre-defined set of colors to new foreground and background colors. 126983afe33SPhil ShaferThe value is a series of "fg/bg" values, separated by a "+". Each 127983afe33SPhil Shaferpair of "fg/bg" values gives the colors to which a basic color is 128983afe33SPhil Shafermapped when used as a foreground or background color. The order is 129983afe33SPhil Shaferthe mappings is: 130983afe33SPhil Shafer 131983afe33SPhil Shafer- black 132983afe33SPhil Shafer- red 133983afe33SPhil Shafer- green 134983afe33SPhil Shafer- yellow 135983afe33SPhil Shafer- blue 136983afe33SPhil Shafer- magenta 137983afe33SPhil Shafer- cyan 138983afe33SPhil Shafer- white 139983afe33SPhil Shafer 140983afe33SPhil ShaferPairs may be skipped, leaving them mapped as normal, as are missing 141983afe33SPhil Shaferpairs or single colors. 142983afe33SPhil Shafer 143983afe33SPhil ShaferFor example consider the following xo_emit call:: 144983afe33SPhil Shafer 145983afe33SPhil Shafer xo_emit("{C:fg-red,bg-green}Merry XMas!!{C:}\n"); 146983afe33SPhil Shafer 147983afe33SPhil ShaferTo turn all colored output to red-on-blue, use eight pairs of 14876afb20cSPhil Shafer"red/blue" mappings separated by plus signs ("+"):: 149983afe33SPhil Shafer 150983afe33SPhil Shafer --libxo colors=red/blue+red/blue+red/blue+red/blue+\ 151983afe33SPhil Shafer red/blue+red/blue+red/blue+red/blue 152983afe33SPhil Shafer 153983afe33SPhil ShaferTo turn the red-on-green text to magenta-on-cyan, give a "magenta" 154983afe33SPhil Shaferforeground value for red (the second mapping) and a "cyan" background 155983afe33SPhil Shaferto green (the third mapping):: 156983afe33SPhil Shafer 157983afe33SPhil Shafer --libxo colors=+magenta+/cyan 158983afe33SPhil Shafer 159983afe33SPhil ShaferConsider the common situation where blue output looks unreadable on a 160983afe33SPhil Shaferterminal session with a black background. To turn both "blue" 161983afe33SPhil Shaferforeground and background output to "yellow", give only the fifth 16276afb20cSPhil Shafermapping, skipping the first four mappings with bare plus signs ("+"):: 163983afe33SPhil Shafer 164983afe33SPhil Shafer --libxo colors=++++yellow/yellow 165*5c5819b2SPhil Shafer 166*5c5819b2SPhil ShaferEncoders 167*5c5819b2SPhil Shafer-------- 168*5c5819b2SPhil Shafer 169*5c5819b2SPhil ShaferIn addition to the four "built-in" formats, libxo supports an 170*5c5819b2SPhil Shaferextensible mechanism for adding encoders. These are activated 171*5c5819b2SPhil Shaferusing the "encoder" keyword:: 172*5c5819b2SPhil Shafer 173*5c5819b2SPhil Shafer --libxo encoder=cbor 174*5c5819b2SPhil Shafer 175*5c5819b2SPhil ShaferThe encoder can include encoder-specific options, separated by either 176*5c5819b2SPhil Shafercolons (":") or plus signs ("+"): 177*5c5819b2SPhil Shafer 178*5c5819b2SPhil Shafer --libxo encoder=csv+path=filesystem+leaf=name+no-header 179*5c5819b2SPhil Shafer --libxo encoder=csv:path=filesystem:leaf=name:no-header 180*5c5819b2SPhil Shafer 181*5c5819b2SPhil ShaferFor brevity, the string "@" can be used in place of the string 182*5c5819b2SPhil Shafer"encoder=". 183*5c5819b2SPhil Shafer 184*5c5819b2SPhil Shafer df --libxo @csv:no-header 185