bencode-pretty 0.1.0

A small program to pretty print data serialized in the bencode format.
bencode-pretty-0.1.0 is not a library.

pretty-bencode

Current Version License: BSD-3-Clause

A small CLI program to pretty print bencode. Just adds indentation and makes ascii-only byte strings print in a readable form. Built using the bendy crate.

Will only ingest valid bencode.

Installation

cargo install pretty-bencode

Usage

Can take a single bencode unit (list, dict, integer or byte string) from stdin.

echo "li1ei2ee" | pretty-bencode
l
    i1e
    i2e
e

Can take any number of bencode units, each from a different file.

pretty-bencode file1 file2 file3

Call with the --string-literal (-s) flag to print it formatted as a rust string literal.

echo "li1ei2ee" | pretty-bencode -s
let pretty_bencode = b"\
l\
        i1e\
        i2e\
e\
"

Byte String Representation

If bytestrings contain only bytes that are printable ASCII (bytes in range 40 <= b < 127) they will be printed as ascii characters. Otherwise they will be printed in hexadecimal. E.g. a byte string containing only one byte with the value zero will be printed as 1:\x00. The 1: is of course the standard bencode byte string length prefix.