Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 30 additions & 18 deletions libxo/libxo-csv.7
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
.\" # Copyright (c) 2021, Juniper Networks, Inc.
.\" # All rights reserved.
.\" # This SOFTWARE is licensed under the LICENSE provided in the
.\" # ../Copyright file. By downloading, installing, copying, or
.\" # ../Copyright file. By downloading, installing, copying, or
.\" # using the SOFTWARE, you agree to be bound by the terms of that
.\" # LICENSE.
.\" # Phil Shafer, May 2021
.\"
.\"
.Dd May 13, 2021
.Dt LIBXO-CSV 7
.Os
Expand All @@ -17,7 +17,8 @@
The
.Nm libxo
library supports a "pluggable" encoder mechanism, and ships with an
encoder for CSV (comma separated values) files. The encoder allows
encoder for CSV (comma separated values) files.
The encoder allows
paths and fields to be selected out of the output contents:
.Bd -literal -offset indent
% df --libxo @csv
Expand Down Expand Up @@ -48,7 +49,8 @@ To allow support for additional encodings, libxo includes a
.Nm libxo -based
applications can automatically use any installed encoder.
.Pp
Use the "encoder=XXX" option to access encoders. The following
Use the "encoder=XXX" option to access encoders.
The following
example uses the "cbor" encoder, saving the output into a file:
.Bd -literal -offset indent
df --libxo encoder=cbor > df-output.cbor
Expand Down Expand Up @@ -81,12 +83,14 @@ The string "@" can be used in place of the string "encoder=".
.Sh The CSV (Comma Separated Values) Encoder
.Nm libxo
ships with a custom encoder for "CSV" files, a common format for
comma separated values. The output of the CSV encoder can be loaded
comma separated values.
The output of the CSV encoder can be loaded
directly into spreadsheets or similar applications.
.Pp
A standard for CSV files is provided in RFC 4180, but since the
format predates that standard by decades, there are many minor
differences in CSV file consumers and their expectations. The CSV
differences in CSV file consumers and their expectations.
The CSV
encoder has a number of options to tailor output to those
expectations.
.Pp
Expand Down Expand Up @@ -150,7 +154,8 @@ In some cases, this may be unacceptable, and a specific list may be
desired.
.Pp
Use the "path" option to limit the processing of output to a specific
hierarchy. The path should be one or more names of containers or
hierarchy.
The path should be one or more names of containers or
lists.
.Pp
For example, if the "list-items" application generates other lists,
Expand All @@ -164,27 +169,31 @@ the user can give "path=top/data/item" as a path:
.Ed
.Pp
Paths are "relative", meaning they need not be a complete set
of names to the list. This means that "path=item" may be sufficient
of names to the list.
This means that "path=item" may be sufficient
for the above example.
.Sh The "leafs" Option
The CSV encoding requires that all lines of output have the same
number of fields with the same order. In contrast, XML and JSON allow
number of fields with the same order.
In contrast, XML and JSON allow
any order (though libxo forces key leafs to appear before other
leafs).
.Pp
To maintain a consistent set of fields inside the CSV file, the same
set of leafs must be selected from each list item. By default, the
set of leafs must be selected from each list item.
By default, the
CSV encoder records the set of leafs that appear in the first list
instance it processes, and extract only those leafs from future
instances. If the first instance is missing a leaf that is desired by
instances.
If the first instance is missing a leaf that is desired by
the consumer, the "leaf" option can be used to ensure that an empty
value is recorded for instances that lack a particular leaf.
.Pp
The "leafs" option can also be used to exclude leafs, limiting the
output to only those leafs provided.
.Pp
In addition, the order of the output fields follows the order in which
the leafs are listed. "leafs=one.two" and "leafs=two.one" give
the leafs are listed; "leafs=one.two" and "leafs=two.one" give
distinct output.
.Pp
So the "leafs" option can be used to expand, limit, and order the set
Expand All @@ -207,7 +216,7 @@ separated by a period ("."):
.Pp
Note that since libxo uses terminology from YANG (:RFC:`7950`), the
data modeling language for NETCONF (:RFC:`6241`), which uses "leafs"
as the plural form of "leaf". libxo follows that convention.
as the plural form of "leaf", libxo follows that convention.
.Sh The "no-header" Option
CSV files typical begin with a line that defines the fields included
in that file, in an attempt to make the contents self-defining:
Expand All @@ -225,16 +234,19 @@ The csv encoder defaults to producing the header line, but the
"no-header" option can be included to avoid the header line.
.Sh The "no-quotes" Option
RFC 4180 specifies that fields containing spaces should be quoted, but
many CSV consumers do not handle quotes. The "no-quotes" option
many CSV consumers do not handle quotes.
The "no-quotes" option
instruct the CSV encoder to avoid the use of quotes.
.Sh The "dos" Option
RFC 4180 defines the end-of-line marker as a carriage return
followed by a newline. This "CRLF" convention dates from the distant
followed by a newline.
This "CRLF" convention dates from the distant
past, but its use was anchored in the 1980s by the `DOS` operating
system.
.Pp
The CSV encoder defaults to using the standard Unix end-of-line
marker, a simple newline. Use the "dos" option to use the `CRLF`
marker, a simple newline.
Use the "dos" option to use the `CRLF`
convention.
.Sh Option Handling
The handling of command-line options is complex, since there are three
Expand Down Expand Up @@ -268,7 +280,7 @@ library first appeared in
The CSV encoder first appeared in
.Fx 13.0 .
.Sh AUTHORS
The
.Nm libxo
was written by
library was written by
.An Phil Shafer Aq Mt phil@freebsd.org .

19 changes: 10 additions & 9 deletions libxo/libxo.3
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
.\" # Copyright (c) 2014, Juniper Networks, Inc.
.\" # All rights reserved.
.\" # This SOFTWARE is licensed under the LICENSE provided in the
.\" # ../Copyright file. By downloading, installing, copying, or
.\" # ../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 December 8, 2014
.Dt LIBXO 3
.Os
Expand Down Expand Up @@ -285,8 +285,9 @@ These functions are mildly compatible with their standard libc
namesakes, but use the format string defined in
.Xr xo_format 5 .
While there is an increased cost for converting the strings, the
output provided can be richer and more useful. See also
.Xr xo_err 3
output provided can be richer and more useful.
See also
.Xr xo_err 3 .
.It Fn xo_warn
.It Fn xo_warnx
.It Fn xo_warn_c
Expand Down Expand Up @@ -380,7 +381,6 @@ Instructs
to use an alternative set of low-level output functions.
.El
.Sh SEE ALSO
.Xr libxo-csv 7,
.Xr xo 1 ,
.Xr xolint 1 ,
.Xr xo_attr 3 ,
Expand All @@ -393,22 +393,23 @@ to use an alternative set of low-level output functions.
.Xr xo_no_setlocale 3 ,
.Xr xo_open_container 3 ,
.Xr xo_open_list 3 ,
.Xr xo_options 7,
.Xr xo_parse_args 3 ,
.Xr xo_set_allocator 3 ,
.Xr xo_set_flags 3 ,
.Xr xo_set_info 3 ,
.Xr xo_set_options 3 ,
.Xr xo_set_style 3 ,
.Xr xo_set_writer 3 ,
.Xr xo_format 5
.Xr xo_format 5 ,
.Xr libxo-csv 7 ,
.Xr xo_options 7
.Sh HISTORY
The
.Nm libxo
library first appeared in
.Fx 11.0 .
.Sh AUTHORS
The
.Nm libxo
was written by
library was written by
.An Phil Shafer Aq Mt phil@freebsd.org .

18 changes: 10 additions & 8 deletions libxo/xo_attr.3
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
.\" # Copyright (c) 2014, Juniper Networks, Inc.
.\" # All rights reserved.
.\" # This SOFTWARE is licensed under the LICENSE provided in the
.\" # ../Copyright file. By downloading, installing, copying, or
.\" # ../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 July, 2014
.Dt LIBXO 3
.Os
Expand All @@ -26,7 +26,8 @@
.Sh DESCRIPTION
The
.Fn xo_attr
function emits attributes for the XML output style. The attribute
function emits attributes for the XML output style.
The attribute
value is recorded in the
.Fa handle
and is attached to the next field that is emitted via a
Expand All @@ -35,7 +36,8 @@ call.
.Pp
The
.Fa name
parameter give the name of the attribute to be encoded. The
parameter give the name of the attribute to be encoded.
The
.Fa fmt
parameter gives a printf-style format string used to format the
value of the attribute using any remaining arguments, or the
Expand All @@ -56,15 +58,15 @@ Since attributes are only emitted in XML, their use should be limited
to meta-data and additional or redundant representations of data
already emitted in other form.
.Sh SEE ALSO
.Xr xo_emit 3 ,
.Xr libxo 3
.Xr libxo 3 ,
.Xr xo_emit 3
.Sh HISTORY
The
.Nm libxo
library first appeared in
.Fx 11.0 .
.Sh AUTHORS
The
.Nm libxo
was written by
library was written by
.An Phil Shafer Aq Mt phil@freebsd.org .

12 changes: 6 additions & 6 deletions libxo/xo_create.3
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
.\" # Copyright (c) 2014, Juniper Networks, Inc.
.\" # All rights reserved.
.\" # This SOFTWARE is licensed under the LICENSE provided in the
.\" # ../Copyright file. By downloading, installing, copying, or
.\" # ../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 December 4, 2014
.Dt LIBXO 3
.Os
Expand Down Expand Up @@ -62,16 +62,16 @@ with a
handle will release any
resources associated with the default handle.
.Sh SEE ALSO
.Xr libxo 3 ,
.Xr xo_emit 3 ,
.Xr xo_set_options 3 ,
.Xr libxo 3
.Xr xo_set_options 3
.Sh HISTORY
The
.Nm libxo
library first appeared in
.Fx 11.0 .
.Sh AUTHORS
The
.Nm libxo
was written by
library was written by
.An Phil Shafer Aq Mt phil@freebsd.org .

21 changes: 11 additions & 10 deletions libxo/xo_emit.3
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
.\" # Copyright (c) 2014, Juniper Networks, Inc.
.\" # All rights reserved.
.\" # This SOFTWARE is licensed under the LICENSE provided in the
.\" # ../Copyright file. By downloading, installing, copying, or
.\" # ../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 December 4, 2014
.Dt LIBXO 3
.Os
Expand Down Expand Up @@ -51,7 +51,7 @@ source code:
"{:characters/%7ju} {d:filename/%s}\\n",
linect, wordct, charct, file);
.Ed
Output can then be generated in various style, using
Output can then be generated in various style, using
the "--libxo" option:
.Bd -literal -offset indent
% wc /etc/motd
Expand Down Expand Up @@ -92,25 +92,26 @@ the "--libxo" option:
.Ed
.Sh RETURN CODE
.Nm
returns a negative value on error. If the
returns a negative value on error.
If the
.Nm XOF_COLUMNS
flag has been turned on for the specific handle using
.Xr xo_set_flags 3 ,
then the number of display columns consumed by the output will be returned.
.Sh SEE ALSO
.Xr xo_open_container 3 ,
.Xr xo_open_list 3 ,
.Xr libxo 3 ,
.Xr xo_emit_f 3 ,
.Xo xo_emit_field 3 ,
.Xr xo_format 5 ,
.Xr libxo 3
.Xr xo_open_container 3 ,
.Xr xo_open_list 3 ,
.Xr xo_format 5
.Sh HISTORY
The
.Nm libxo
library first appeared in
.Fx 11.0 .
.Sh AUTHORS
The
.Nm libxo
was written by
library was written by
.An Phil Shafer Aq Mt phil@freebsd.org .

12 changes: 6 additions & 6 deletions libxo/xo_emit_err.3
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
.\" # Copyright (c) 2014, Juniper Networks, Inc.
.\" # All rights reserved.
.\" # This SOFTWARE is licensed under the LICENSE provided in the
.\" # ../Copyright file. By downloading, installing, copying, or
.\" # ../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 December 4, 2014
.Dt LIBXO 3
.Os
Expand Down Expand Up @@ -66,17 +66,17 @@ parameter.
xo_err(1, "cannot open file '%s'", filename);
.Ed
.Sh SEE ALSO
.Xr libxo 3 ,
.Xr xo_emit 3 ,
.Xr xo_format 5 ,
.Xr xo_err 3 ,
.Xr libxo 3
.Xr xo_format 5
.Sh HISTORY
The
.Nm libxo
library first appeared in
.Fx 11.0 .
.Sh AUTHORS
The
.Nm libxo
was written by
library was written by
.An Phil Shafer Aq Mt phil@freebsd.org .

Loading