.Dd 19 January 2018
.Dt PPBERT 1
.Os
.Sh NAME
.Nm ppbert
.Nd pretty print structures encoded in Erlang's External Term Format
.Sh SYNOPSIS
.Nm
.Op Ar OPTIONS
.Op Ar FILES Nm ...
.Sh DESCRIPTION
.Nm
decodes binary-encoded Erlang terms (often called BERT terms) and pretty-prints them.
.Pp
.Nm
can decode .bert files (bertconf), .bert2 files (rig), and log files (disk_log).
The output format can either be pretty-printed as Erlang terms
(good for looking at the structure of a file),
or as one-line JSON values (useful for grepping or piping into jq).
.Pp
.Nm
was created to make pretty-printing such files faster than what
is possible in Erlang, and its design follows the Unix philosophy
as much as possible (e.g., reading from
.Em
stdin
and writing to
.Em
stdout.)
.Pp
.Nm
accepts the following options:
.Bl -tag -width left
.It Fl 2 , Fl -bert2
Parse a .bert2 file
.It Fl d , Fl -disk-log
Parse an Erlang disk_log file
.It Fl j , Fl -json
Output in JSON. No pretty printing is performed
with this option; pipe into jq if necessary.
.It Fl -transform-proplists
Erlang proplists are converted to JSON objects;
ignored if
.Fl -json
is not provided.
.It Fl i Ar num , Fl -indent-width Ar num
Set the indentation to
.Ar num
spaces. Default = 2.
.It Fl m Ar num , Fl -max-terms-per-line Ar num
Set the maximum number of basic terms
(i.e., numbers, strings, atoms)
that may be printed on a single line.
Default = 4.
.It Fl v , -verbose
Show the time it takes to parse and pretty print
a file.
.It Fl p , -parse
Do not pretty print the file, simply parse it.
Useful to verify if a file is well-formed.
.It Fl h , -help
Display help
.It Fl V , -version
Display version
.El
.Sh RETURN VALUES
.Nm
returns 0 if all files have been successfully processed,
and 1 if any file failed to parse.
.Sh COMPATIBILITY
.Nm
supports a subset of the types supported by the
Erlang External Term Format, namely those that can
represent data structures (see the list below).
.Nm
does not support types such as PIDs, ports,
references, or functions.
.Pp
Supported types:
.Bl -item
.It
Small integers (tag: 97);
.It
Integers (tag: 98);
.It
Floating-point numbers (tags: 70, 99);
.It
Big integers (tags: 110, 111);
.It
Latin-1 atoms (tags: 100, 115);
.It
UTF-8 atoms (tags: 118, 119);
.It
Strings (tag: 107);
.It
Binaries (tag: 109);
.It
Tuples (tags: 104, 105);
.It
Lists (tags: 106, 108);
.It
Maps (tag: 116).
.El
.Sh EXAMPLES
Pretty print the file foo.bert:
.Bd -literal -offset indent
$ ppbert foo.bert
.Ed
.Pp
Pretty print as JSON the all the .bert2 files in the current directory:
.Bd -literal -offset indent
$ ppbert -2 --json *.bert2
.Ed
.Pp
Pretty print the disk_log files in the current directory:
.Bd -literal -offset indent
$ ppbert -d *.LOG.[0-9]*
.Ed
.Pp
Pretty print from stdin:
.Bd -literal -offset indent
$ cat foo.bert | ppbert -
OR
$ cat foo.bert | ppbert
.Ed
.Sh LICENSE
.Nm
MIT-licensed; see LICENSE for the terms of use.
.Sh AUTHORS
Vincent Foley <http://github.com/gnuvince>