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
14 .Nm xo_parse_args , xo_set_program
15 .Nd detect, parse, and remove arguments for libxo
21 .Fn xo_parse_args "int argc" "char **argv"
23 .Fn xo_set_program "const char *name"
27 function is used to process command-line arguments.
30 options are processed and removed
31 from the argument list so the calling application does not
33 If successful, a new value for argc is returned.
34 On failure, a message it emitted and -1 is returned.
35 .Bd -literal -offset indent
36 argc = xo_parse_args(argc, argv);
43 the application can process the remaining arguments in a normal manner.
46 uses command line options to trigger rendering behavior.
47 The following options are recognised:
49 .Bl -tag -width "--libxo"
55 \-\^\-libxo:<brief-options>
58 Options is a comma-separated list of tokens that correspond to output
59 styles, flags, or features:
61 .Bl -tag -width "12345678"
64 Enable "Do The Right Thing" mode
68 Set the indentation level
70 Add info attributes (HTML)
74 Emit the key attribute for keys (XML)
80 Log (via stderr) each syslog message (via
83 Ignore the {h:} modifier (TEXT, HTML)
85 Do not initialize the locale setting
87 Prevent retaining formatting information
89 Do not emit a top set of braces (JSON)
91 Pretend the 1st output item was not 1st (JSON)
93 Emit pretty-printed output
95 Force retaining formatting information
99 Replace XML-friendly "-"s with JSON friendly "_"s e
101 Add the 'units' (XML) or 'data-units (HTML) attribute
103 Emit warnings when libxo detects bad calls
109 Add XPath expressions (HTML)
114 are single letter commands, designed for those with
115 too little patience to use real tokens.
116 No comma separator is used.
118 .It Sy "Token Action"
119 .It "H " "Enable HTML output (XO_STYLE_HTML)"
120 .It "I " "Enable info output (XOF_INFO)"
121 .It "i<num> " "Indent by <number>"
122 .It "J " "Enable JSON output (XO_STYLE_JSON)"
123 .It "P " "Enable pretty-printed output (XOF_PRETTY)"
124 .It "T " "Enable text output (XO_STYLE_TEXT)"
125 .It "W " "Enable warnings (XOF_WARN)"
126 .It "X " "Enable XML output (XO_STYLE_XML)"
127 .It "x " "Enable XPath data (XOF_XPATH)"
132 function sets name of the program as reported by
138 The program name is initialized by
140 but subsequent calls to
142 can override this value.
144 Note that the value is not copied, so the memory passed to
148 must be maintained by the caller.
156 library first appeared in
161 .An Phil Shafer Aq Mt phil@freebsd.org .