6 releases

Uses old Rust 2015

0.3.2 Mar 13, 2021
0.3.1 Jan 6, 2021
0.3.0 Aug 29, 2020
0.2.1 Sep 12, 2018
0.1.0 Aug 20, 2018

#27 in Command-line interface

Download history 1058/week @ 2021-02-24 1486/week @ 2021-03-03 1870/week @ 2021-03-10 1427/week @ 2021-03-17 1774/week @ 2021-03-24 2413/week @ 2021-03-31 2284/week @ 2021-04-07 1887/week @ 2021-04-14 1300/week @ 2021-04-21 1161/week @ 2021-04-28 1543/week @ 2021-05-05 1758/week @ 2021-05-12 1673/week @ 2021-05-19 1750/week @ 2021-05-26 1998/week @ 2021-06-02 1276/week @ 2021-06-09

7,049 downloads per month
Used in 10 crates (8 directly)

MIT/Apache

86KB
1K SLoC

Pretty-print tree-like structures

The ptree crate supports output formatting due to a user-provided configuration file and/or environment variables. Different output styles

Usage

[dependencies]
ptree = "0.3"

Constructing a tree

There are two main ways of using ptree to print a tree-like data structure. The first is to implement TreeItem for your structure. The second is to create a new tree, either using TreeBuilder or by manually constructing StringItems.

The ptree crate includes implementations of TreeItem for some common types, including a custom StringItem and petgraph::Graph.

Printing the tree

A tree can be printed to standard output using print_tree, or to an arbitrary writer using write_tree. Both functions have variants which take a PrintConfig that controls the output. Text is formatted using ansi-term, which allows changing colors and styles of the printed text.

User configuration

By default, ptree loads configuration from a user configuration file. This allows end users to globally configure the output format for all applications using ptree. Applications can use this configuration directly, modify it, or ignore it altogether.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1.5–2.5MB
~57K SLoC