Skip to content
nathymaticPublic

About

a small directory tree CLI written in Rust (again) because apparently we need to appreciate the wonders and beauty of the family history of our files and folders

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tree

a tiny directory tree CLI written in Rust because apparently listing files normally isn't enough anymore!!!

About

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
  • recursive directory traversal
  • error handling (especially with Result<T, E>.. FOREVER.)
  • Rust's ownership and borrowing system (LIKE ALWAYS. ALWAYS. ALWAYS. this is inevitable, really...)

Features

  • 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

Quick Start

Requirements

  • Rust
  • Cargo

Build from Source

clone the repository:

git clone https://github.com/jayywashere/tree
cd tree

build the release executable:

cargo build --release

or maybe you actually don't need to, because tree.sh does it for ya

Usage

display the current directory's tree:

tree .

or specify a directory:

tree /path/to/directory

if 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 . --all

because apparently some files prefer to live in the shadows . . .

Ignore Entries

ignore entries by name:

tree . --ignore=target

ignore multiple names:

tree . --ignore=target,.git

the 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.)

Limit Traversal Depth

show only the root directory:

tree . --depth=0

show the root and its immediate entries:

tree . --depth=1

allow traversal up to two levels below the root:

tree . --depth=2

the depth limit controls how far the directory explorer descends, because sometimes you don't need to see the entire filesystem's family history!!

Combine Options

you can combine supported options:

tree /path/to/directory --all --ignore=target,.git --depth=2

mix and match!! just don't repeat the same flag, or tree will complain. (yes, even if you give it different values.)

How It Works

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 !

Why I Made This

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

License

See LICENSE.

About

a small directory tree CLI written in Rust (again) because apparently we need to appreciate the wonders and beauty of the family history of our files and folders

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages