Crates.io | rust_tree |
lib.rs | rust_tree |
version | 0.1.4 |
source | src |
created_at | 2023-05-07 12:54:12.536449 |
updated_at | 2023-05-07 18:25:05.578559 |
description | tree is a cross-platform tree application and library that produces an indented directory listing of files. |
homepage | https://github.com/peteretelej/tree |
repository | https://github.com/peteretelej/tree |
max_upload_size | |
id | 859137 |
size | 68,125 |
tree
is a command-line utility that recursively displays the directory structure of a given path in a tree-like format, inspired by the Unix tree
command. It is implemented in Rust and aims to provide a fast and efficient alternative with additional features.
-L
flag-f
flag-i
flag-a
flag-P
flag-s
flag-h
flagS-C
flag-n
flag-I
flag-o
flag--filelimit
flagdirsfirst
flagUsing this project to learn Rust, so it's not production ready. Feel free to PR for any improvements.
Ready to use binaries for various platforms are available on the Releases Page (Windows, MacOS, Linux).
tree
binariesIf you have Rust and Cargo installed, you can build the project by running:
git clone https://github.com/peteretelej/tree.git
cd tree
cargo build --release
./target/release/tree -L 2 .
# copy tree binary to a PATH directory
The resulting binary will be located at ./target/release/tree.
./tree [FLAGS] [OPTIONS] [PATH]
For example
./tree -L 2 .
# -L 2: displays upto 2 levels of recursion
use rust_tree::tree::{list_directory, options::TreeOptions};
fn main() {
let path = ".";
let options = TreeOptions {
full_path: true,
no_indent: true,
..Default::default()
};
list_directory(path, &options).unwrap();
}
Using the bytes_to_human_readable
function to print human readable file sizes
use rust_tree::utils::bytes_to_human_readable;
use std::fs;
fn main() {
let metadata = fs::metadata("my_file.txt").unwrap();
let size = metadata.len();
let size_str = bytes_to_human_readable(size);
println!("File size: {}", size_str);
}
Contributions are welcome! If you have any suggestions, feature requests, or bug reports, please feel free to open an issue or submit a pull request on the GitHub repository.
MIT