Tree Decorator
An utility rust lib to render pleasing tree structures at terminal programs.
It's goal is to simplify tree structure display while ensuring a good looking to it. So it just handle strings, returning the expected result (with current level and supplied styles) and nothing more.
Already comes with a standard visual implementation, so is ready to use, but a custom implementation is very easy to set.
See Documentation.
Dependencies
As little, or none, as needed. Until now, only log will be added, in the near future, to simplify macro calls.
Usage
Before any use, decorator must be build at least once.
use ;
Outputs:
Root item
├ Item A
├ Item B
├ Item C
└ Item D
Explanation
Everything works around tree_item!
macro, it has some specific features that must be explained.
Each section is optional, as long the order is preserved.
tree_item!(
[styles],
"A literal string",
[string interpolation args]
)
Styles
A style which will be applied to that tree item.
Every opt-in style must match the name defined at Style struct fields (please check Documentation) and multiple ones can be declared using ;
as separator to them.
Declaring only it's name will apply a style item default enable value. (Not to be confused with std::default::Default
it could not be the same value)
Example
use tree_item;
tree_item!;
Some style items could support more values than enable or disable.
Such as entry
:
use ;
tree_item!;
Note: Order doesn't matter at styles defination.
Literal String and Interpolation Args
Both of these is the same as defined at std::format.
License
Everything is licensed under MIT License.