Crates.io | ptree2 |
lib.rs | ptree2 |
version | 1.0.0 |
source | src |
created_at | 2024-07-28 19:14:55.088136 |
updated_at | 2024-07-28 19:14:55.088136 |
description | Pretty-print tree-like structures |
homepage | |
repository | https://github.com/jthulhu/ptree2 |
max_upload_size | |
id | 1318172 |
size | 188,276 |
Warning. (28 july 2024) This is a fork of the now seemingly unmaintained crate
ptree
. This fork has been created out of the need of
bumping the version of the dependencies of the ptree
crate. This means that there are a few
points to keep in mind:
The ptree
crate supports output formatting due to a user-provided configuration file and/or
environment variables.
[dependencies]
ptree = { version = "1", package = "ptree2" }
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 StringItem
s.
The ptree
crate includes implementations of TreeItem
for some common types, including a custom StringItem
and petgraph::Graph
.
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.
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.
Licensed under either of
at your option.
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.