a tiny directory tree CLI written in Rust because apparently listing files normally isn't enough anymore!!!
tree is a command-line directory tree viewer written in Rust . . . (AS ALWAYS???????)
it displays files and directories in a hierarchical tree structure, right in your terminal!! (because apparently the filesystem needed a family tree too??)
you can choose which directory to explore, include hidden entries, ignore specific names, and limit how deep the traversal goes!! all through a few command-line arguments!!
this project combines recursive filesystem exploration with practical systems such as argument parsing, path validation, configurable traversal depth, and error handling..
i made this to practice working with:
- command-line argument
parsing recursivedirectorytraversal- error handling (especially with
Result<T, E>.. FOREVER.) Rust's ownership and borrowing system (LIKE ALWAYS. ALWAYS. ALWAYS. this is inevitable, really...)
- display files and directories in a hierarchical tree structure
- explore a specified directory or default to the current directory
- include hidden entries using
--all - ignore selected file and directory names using
--ignore - limit directory traversal using
--depth - validate paths and reject invalid directory arguments
- detect duplicate flags
- handle command-line errors without silently accepting invalid arguments
- a recursive directory explorer all in all
RustCargo
clone the repository:
git clone https://github.com/jayywashere/tree
cd treebuild the release executable:
cargo build --releaseor maybe you actually don't need to, because tree.sh does it for ya
display the current directory's tree:
tree .or specify a directory:
tree /path/to/directoryif you don't provide a path, tree defaults to the current directory!! (convenient, right??) oh, um, i actually don't know!!
Include Hidden Entries
display hidden files and directories, too:
tree . --allbecause apparently some files prefer to live in the shadows . . .
ignore entries by name:
tree . --ignore=targetignore multiple names:
tree . --ignore=target,.gitthe specified names are ignored throughout the directory traversal, so matching entries won't appear even when they're nested inside other directories!! (no escape from the blacklist.)
show only the root directory:
tree . --depth=0show the root and its immediate entries:
tree . --depth=1allow traversal up to two levels below the root:
tree . --depth=2the depth limit controls how far the directory explorer descends, because sometimes you don't need to see the entire filesystem's family history!!
you can combine supported options:
tree /path/to/directory --all --ignore=target,.git --depth=2mix and match!! just don't repeat the same flag, or tree will complain. (yes, even if you give it different values.)
tree recursively explores directories and renders their entries using tree-style branch characters. its argument parser handles positional paths and supported flags, while its directory model manages filesystem traversal and depth limits.
hidden entries are excluded by default, and ignored names are filtered out during traversal. invalid paths, unsupported flags, malformed arguments, and duplicate flags are reported as errors !
more practice. even if this project serves no convenience!!
anyway!! a directory tree viewer is basically labor involving recursion, filesystem APIs, argument parsing, configurable behavior, error handling, and modular application architecture.
IN SHORT: RUST FOREVER AND EVER
See LICENSE.