Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Shafer committed May 12, 2017
2 parents c3e981b + a199ecc commit 5102856
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 6 deletions.
33 changes: 29 additions & 4 deletions doc/libxo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,8 @@ styles, flags, or features:
|-------------+-------------------------------------------------------|
| color | Enable colors/effects for display styles (TEXT, HTML) |
| dtrt | Enable "Do The Right Thing" mode |
| flush | Flush after every libxo function call |
| flush-line | Flush after every line (line-buffered) |
| html | Emit HTML output |
| indent=xx | Set the indentation level |
| info | Add info attributes (HTML) |
Expand All @@ -1479,7 +1481,7 @@ styles, flags, or features:
| pretty | Emit pretty-printed output |
| retain | Force retaining formatting information |
| text | Emit TEXT output |
| underscores | Replace XML-friendly "-"s with JSON friendly "_"s e |
| underscores | Replace XML-friendly "-"s with JSON friendly "_"s |
| units | Add the 'units' (XML) or 'data-units (HTML) attribute |
| warn | Emit warnings when libxo detects bad calls |
| warn-xml | Emit warnings in XML |
Expand All @@ -1489,6 +1491,29 @@ styles, flags, or features:

The brief options are detailed in ^LIBXO_OPTIONS^.

Most of these option are simple and direct, but some require
additional details:

- "flush-line" performs line buffering, even when the output is not
directed to a TTY device.
- "info" generates additional data for HTML, encoded in attributes
using names that state with "data-".
- "keys" adds a "key" attribute for XML output to indicate that a leaf
is an identifier for the list member.
- "no-humanize"avoids "humanizing" numeric output (see
humanize_number(3) for details).
- "no-locale" instructs libxo to avoid translating output to the
current locale.
- "no-retain" disables the ability of libxo to internally retain
"compiled" information about formatting strings.
- "underscores" can be used with JSON output to change XML-friendly
names with dashes into JSON-friendly name with underscores.
- "warn" allows libxo to emit warnings on stderr when application code
make incorrect calls.
- "warn-xml" causes those warnings to be placed in XML inside the
output.


* The libxo API

This section gives details about the functions in libxo, how to call
Expand Down Expand Up @@ -2893,9 +2918,9 @@ which include the following:
Compiler warnings are a very good thing, but recent compiler version
have added some very pedantic checks. While every attempt is made to
keep libxo code warning-free, warnings are now optional. If you are
doing development work on libxo, it is required that you use
--enable-warnings to keep the code warning free, but most users need
not use this option.
doing development work on libxo, it is required that you
use --enable-warnings to keep the code warning free, but most users
need not use this option.

libxo provides the --enable-text-only option to reduce the footprint
of the library for smaller installations. XML, JSON, and HTML
Expand Down
7 changes: 6 additions & 1 deletion libxo/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ man3_files = \
man5_files = \
xo_format.5

man_MANS = ${man3_files} ${man5_files}
man7_files = \
xo_options.7

man_MANS = ${man3_files} ${man5_files} ${man7_files}

EXTRA_DIST = \
${man_MANS}
Expand All @@ -87,3 +90,5 @@ install-data-hook:
cat ../libxo/add.man >> ${DESTDIR}${man3dir}/$$file ; done
for file in ${man5_files}; do \
cat ../libxo/add.man >> ${DESTDIR}${man5dir}/$$file ; done
for file in ${man7_files}; do \
cat ../libxo/add.man >> ${DESTDIR}${man7dir}/$$file ; done
1 change: 1 addition & 0 deletions libxo/libxo.c
Original file line number Diff line number Diff line change
Expand Up @@ -2059,6 +2059,7 @@ static xo_mapping_t xo_xof_names[] = {
{ XOF_COLUMNS, "columns" },
{ XOF_DTRT, "dtrt" },
{ XOF_FLUSH, "flush" },
{ XOF_FLUSH_LINE, "flush-line" },
{ XOF_IGNORE_CLOSE, "ignore-close" },
{ XOF_INFO, "info" },
{ XOF_KEYS, "keys" },
Expand Down
2 changes: 1 addition & 1 deletion libxo/xo_format.5
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ The format string has the form:
\(aq%\(aq format\-modifier * format\-character
.Ed
.Pp
The format\- modifier can be:
The format\-modifier can be:
.Bl -bullet
.It
a \(aq#\(aq character, indicating the output value should be prefixed with
Expand Down
147 changes: 147 additions & 0 deletions libxo/xo_options.7
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
.\" #
.\" # Copyright (c) 2014-2017, Juniper Networks, Inc.
.\" # All rights reserved.
.\" # This SOFTWARE is licensed under the LICENSE provided in the
.\" # ../Copyright file. By downloading, installing, copying, or
.\" # using the SOFTWARE, you agree to be bound by the terms of that
.\" # LICENSE.
.\" # Phil Shafer, July 2014
.\"
.Dd May 11, 2017
.Dt LIBXO 3
.Os
.Sh NAME
.Nm xo_options
.Nd common options for libxo\-based commands
.Sh DESCRIPTION
.Pp
.Nm libxo
allows the rendering of data into
various output styles, including
.Em text ,
.Em XML ,
.Em JSON ,
and
.Em HTML .
.Nm libxo
uses command line options to trigger rendering behavior.
Options are recognised in three forms:
.Bl -bullet
.It
\-\-libxo <options>
.It
\-\-libxo=<options>
.It
\-\-libxo:<brief\-options>
.El
.Pp
The first two forms accept a comma\-separated set of words, detailed
below, while the third form accepts a set of letters, also below.
The triggered functionality is identical.
.Bl -column "Token2341234"
.It Sy "Option " "Action"
.It "color " "Enable colors/effects for display styles (TEXT, HTML)"
.It "flush " "Flush after each emit call"
.It "flush\-line " "Flush each line of output"
.It "html " "Emit HTML output"
.It "indent=xx " "Set the indentation level"
.It "info " "Add info attributes (HTML)"
.It "json " "Emit JSON output"
.It "keys " "Emit the key attribute for keys (XML)"
.It "log\-gettext" "Log (via stderr) each gettext(3) string lookup"
.It "log\-syslog " "Log (via stderr) each syslog message (via xo_syslog)"
.It "no\-humanize" "Ignore the {h:} modifier (TEXT, HTML)"
.It "no\-locale " "Do not initialize the locale setting"
.It "no\-retain " "Prevent retaining formatting information"
.It "pretty " "Emit pretty\-printed output"
.It "retain " "Force retaining formatting information"
.It "text " "Emit TEXT output"
.It "underscores" "Replace XML\-friendly \"\-\"s with JSON friendly \"_\"s"
.It "units " "Add the 'units' (XML) or 'data\-units (HTML) attribute"
.It "warn " "Emit warnings when libxo detects bad calls"
.It "warn\-xml " "Emit warnings in XML"
.It "xml " "Emit XML output"
.It "xpath " "Add XPath expressions (HTML)"
.El
.Pp
The brief options are a set of single\-letter aliases for the longer
terms, used as a single string:
.Bl -column "Value" "Equivalent Token"
.It Sy "Value" "Equivalent Token"
.It "c
.It "f " "flush"
.It "F " "flush\-line"
.It "H " "html"
.It "I " "info"
.It "i<num>" "indent=<num>"
.It "J " "json"
.It "k " "keys"
.It "n " "no\-humanize"
.It "P " "pretty"
.It "T " "text"
.It "U " "units"
.It "u " "underscore
.It "W " "warn"
.It "X " "xml"
.It "x " "xpath"
.El
.Pp
Most of these option are simple and direct, but some require
additional details:
.Pp
.Fa "flush\-line"
performs line buffering, even when the output is not directed to
a TTY device.
.Pp
.Fa info
generates additional data for HTML, encoded in attributes using
names that state with "data\-".
.Pp
.Fa keys
adds a "key" attribute for XML output to indicate that a leaf is
an identifier for the list member.
.Pp
.Fa no\-humanize
avoids "humanizing" numeric output (see
.Xr humanize_number 3
for details).
.Pp
.Fa no\-locale
instructs
.Nm libxo
to avoid translating output to the current locale.
.Pp
.Fa no\-retain
disables the ability of
.Nm libxo
to internally retain "compiled" information about formatting strings.
.Pp
.Fa underscores
can be used with
.Em JSON
output to change
.Em XML \-friendly
names with dashes into
.Em JSON \-friendly
name with underscores.
.Pp
.Fa warn
allows
.Nm libxo
to emit warnings on stderr when application code make incorrect calls.
.Fa warn\-xml causes those warnings to be placed in
.Em XML
inside the output.
.Sh EXAMPLES
The following are three example invocations of
.Xr ps 1 :
.Bd -literal
ps \-\-libxo json,pretty,warn \-ux

ps \-\-libxo=xml \-lg

ps \-\-libxo:Hxc 1
.Ed
.Sh SEE ALSO
.Xr libxo 3 ,
.Xr xo_format 5

0 comments on commit 5102856

Please sign in to comment.