ppbert

A simple command-line utility to pretty print structures encoded using Erlang's External Term Format. The input is read from stdin or a file and written to stdout, making ppbert a good candidate for shell pipelines.

At the moment, ppbert supports only a subset of the field types of the External Term Format:

Supported types:

Usage

``` $ ppbert -h ppbert 0.2.2 Vincent Foley Pretty print structure encoded in Erlang's External Term Format

USAGE: ppbert [OPTIONS] []

FLAGS: -h, --help Prints help information -V, --version Prints version information

OPTIONS: -i, --indent-width -m, --max-terms-per-line

ARGS: ...

$ ppbert mini_dict.bert [ {host, "localhost"}, {port, 80}, { headers, [ { <<"X-Real-Ip">>, {127, 0, 0, 1} }, {<<"Keep-alive">>, true} ] } ]

$ printf "\x83\x77\x04atom" | ppbert atom ```

Performance

Ppbert is written in Rust and offers an appreciable performance gain over using Erlang's erlang:binary_to_term/1 and io:format/2.

```sh $ cat erl_ppbert

!/usr/bin/env escript

main(Args) -> lists:foreach(fun (Filename) -> {ok, Binary} = file:readfile(Filename), io:format("~p~n", [binaryto_term(Binary)]) end, Args).

$ du large.bert 96M large.bert

$ time ./erl_ppbert large.bert >/dev/null

real 1m10.968s user 0m49.644s sys 0m13.628s

$ time ppbert large.bert >/dev/null

real 0m6.902s user 0m6.116s sys 0m0.452s ```

Future work