rudu
A fast, parallel Rust CLI tool for analyzing directory sizes and finding the largest directories under a given path. Think of it as a modern, performant alternative to du with a focus on identifying space-consuming directories quickly.
Features
- 🚀 Fast parallel processing using Rayon for concurrent directory traversal
- 📊 Human-readable output with formatted file sizes (KB, MB, GB, etc.)
- 🎯 Top-N results - show only the largest directories that matter
- 🛡️ Safe symlink handling - doesn't follow symbolic links to prevent infinite loops
- 📁 Flexible path input - analyze any directory, defaults to root (
/) - 🔧 Simple CLI interface with sensible defaults
Installation
Quick Install (Recommended)
One-liner installation for Linux and macOS:
|
Or download and run the installer:
Custom installation directory:
INSTALL_DIR=/.local/bin |
Package Managers
Homebrew (macOS)
# Add the tap (once the formula is published)
Cargo (All platforms)
Linux Distribution Packages
Debian/Ubuntu (.deb):
# Download the .deb package from releases
Red Hat/Fedora/CentOS (.rpm):
# Use the provided RPM spec file to build
Arch Linux (AUR):
# Use the provided PKGBUILD
AppImage (Universal Linux):
# Download and run
Pre-built Binaries
Download the latest release for your platform from the releases page:
- Linux x86_64:
rudu-linux-x86_64.tar.gz - Linux x86_64 (musl):
rudu-linux-x86_64-musl.tar.gz - macOS x86_64:
rudu-macos-x86_64.tar.gz - macOS ARM64:
rudu-macos-aarch64.tar.gz
Extract and install:
# Example for Linux
From Source
Using Make
# or
Using Cargo
The binary will be available at target/release/rudu.
Verification
After installation, verify it works:
Usage
Basic Usage
# Analyze current directory, show top 10 largest subdirectories
# Analyze root directory (default)
# Analyze specific directory
# Show top 20 largest directories
# Show top 5 largest directories with long flag
Example Output
Scanning directory: /home/user/Documents
1. 1.2 GB /home/user/Documents/Videos
2. 456.7 MB /home/user/Documents/Photos
3. 123.4 MB /home/user/Documents/Projects/rust-project
4. 89.2 MB /home/user/Documents/Downloads
5. 45.6 MB /home/user/Documents/Books
Command Line Options
path- Root directory to analyze (default:/)-n, --number <NUMBER>- Number of top results to show (default: 10)-h, --help- Show help information-V, --version- Show version information
How It Works
- Recursive Traversal: Uses
walkdirto recursively walk through all files in the directory tree - Size Aggregation: For each file, adds its size to all ancestor directories up to the root
- Parallel Sorting: Uses Rayon to sort results in parallel for better performance
- Human-Readable Output: Formats byte sizes using decimal units (KB, MB, GB, etc.)
Development
Prerequisites
- Rust 1.75 or later
- Cargo (comes with Rust)
Building
# Clone the repository
# Build in debug mode
# Build in release mode (optimized)
# Run directly with cargo
Testing
# Run all tests
# Run tests with output
# Run specific test
Code Structure
src/main.rs- CLI interface and main application logicsrc/lib.rs- Core directory size computation algorithmCargo.toml- Project configuration and dependencies
Dependencies
- clap - Command-line argument parsing with derive macros
- walkdir - Recursive directory traversal
- humansize - Human-readable file size formatting
- rayon - Data parallelism for sorting
- tempfile - Temporary file handling for tests
Contributing
We welcome contributions! Here's how you can help:
Setting Up Development Environment
- Fork the repository
- Clone your fork:
git clone https://github.com/ayungavis/rudu.git - Create a feature branch:
git checkout -b feature/your-feature-name - Make your changes
- Run tests:
cargo test - Run clippy for linting:
cargo clippy - Format code:
cargo fmt - Commit your changes:
git commit -m "Add your feature" - Push to your fork:
git push origin feature/your-feature-name - Create a Pull Request
Code Style
- Follow Rust standard formatting (
cargo fmt) - Ensure all clippy warnings are addressed (
cargo clippy) - Write tests for new functionality
- Add documentation comments for public functions
- Keep functions focused and well-named
Areas for Contribution
- Performance improvements - Optimize directory traversal or sorting
- Additional output formats - JSON, CSV, or other structured formats
- Filtering options - Exclude certain file types or directories
- Cross-platform testing - Ensure compatibility across different operating systems
- Documentation - Improve examples, add more detailed explanations
- Error handling - Better error messages and recovery
- Configuration - Support for config files or environment variables
Running Benchmarks
# Add criterion to dev-dependencies if implementing benchmarks
Debugging
# Run with debug logging
RUST_LOG=debug
# Run with backtraces on panic
RUST_BACKTRACE=1
CI/CD Pipeline
This project uses GitHub Actions for continuous integration and deployment:
-
CI Pipeline (
.github/workflows/ci.yml):- Tests on multiple Rust versions (stable, beta, nightly)
- Cross-platform testing (Linux, Windows, macOS)
- Code formatting checks (
cargo fmt) - Linting with Clippy (
cargo clippy) - Code coverage reporting with Codecov
- Documentation building
- MSRV (Minimum Supported Rust Version) verification
-
Security Audit (
.github/workflows/security-audit.yml):- Daily security vulnerability scans with
cargo audit - License and dependency checking with
cargo deny - Runs on every push and pull request
- Daily security vulnerability scans with
-
Release Pipeline (
.github/workflows/release.yml):- Automated releases when tags are pushed
- Cross-platform binary builds
- Automatic publishing to crates.io
- GitHub release creation with binaries
Setting up CI/CD
To enable all CI/CD features, you'll need to:
- For code coverage: Sign up at Codecov and link your repository
- For releases: Add a
CRATES_TOKENsecret to your GitHub repository settings- Get your token from crates.io/me
- Add it as a repository secret named
CRATES_TOKEN
Running CI checks locally
# Run the same checks as CI
Performance Considerations
- Uses parallel processing where beneficial (sorting large result sets)
- Avoids following symbolic links to prevent infinite loops
- Efficiently aggregates sizes by bubbling up through directory hierarchy
- Memory usage scales with the number of directories, not files
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built with the excellent Rust ecosystem
- Inspired by traditional Unix
ducommand - Uses Rayon for efficient parallel processing
Roadmap
- Add JSON/CSV output formats
- Implement directory exclusion patterns
- Add progress bar for large directory scans
- Support for following symbolic links (optional)
- Configuration file support
- Windows-specific optimizations
Found a bug or have a feature request? Please open an issue on GitHub.