7 unstable releases

Uses old Rust 2015

0.4.0 Oct 27, 2021
0.3.2 Mar 13, 2021
0.3.1 Jan 6, 2021
0.3.0 Aug 29, 2020
0.1.0 Aug 20, 2018

#104 in Command-line interface

Download history 4064/week @ 2023-12-16 2293/week @ 2023-12-23 2927/week @ 2023-12-30 4481/week @ 2024-01-06 4467/week @ 2024-01-13 4515/week @ 2024-01-20 4160/week @ 2024-01-27 4985/week @ 2024-02-03 5913/week @ 2024-02-10 5690/week @ 2024-02-17 3977/week @ 2024-02-24 4722/week @ 2024-03-02 11229/week @ 2024-03-09 14883/week @ 2024-03-16 6137/week @ 2024-03-23 6477/week @ 2024-03-30

39,353 downloads per month
Used in 175 crates (40 directly)

MIT/Apache

85KB
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.4"

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.7–3MB
~60K SLoC