clean-dev-dirs 1.0.0

A fast CLI tool for recursively cleaning Rust target/ and Node.js node_modules/ directories to reclaim disk space
clean-dev-dirs-1.0.0 is not a library.
Visit the last successful build: clean-dev-dirs-2.0.1

clean-dev-dirs

A fast and efficient CLI tool for recursively cleaning Rust target/ and Node.js node_modules/ directories to reclaim disk space.

๐Ÿš€ Features

  • Multi-language support: Clean both Rust (target/) and Node.js (node_modules/) build artifacts
  • Parallel scanning: Fast directory traversal using multithreading
  • Smart filtering: Filter by project size, modification time, and project type
  • Interactive mode: Choose which projects to clean with an interactive interface
  • Dry-run mode: Preview what would be cleaned without actually deleting anything
  • Progress indicators: Real-time feedback during scanning and cleaning operations
  • Detailed statistics: See total space that can be reclaimed before cleaning

๐Ÿ’ก Inspiration

This project is inspired by cargo-clean-all, a Rust-specific tool for cleaning cargo projects. I've improved upon the original concept with:

  • Multi-language support: Extended beyond Rust to support Node.js projects
  • Parallel scanning: Significantly faster directory traversal using multithreading
  • Cleaner code architecture: Well-structured, modular codebase for better maintainability

๐Ÿ“ฆ Installation

From Source

git clone https://github.com/your-username/clean-dev-dirs.git
cd clean-dev-dirs
cargo install --path .

Using Cargo

cargo install clean-dev-dirs

๐Ÿ›  Usage

Basic Usage

# Clean all development directories in the current directory
clean-dev-dirs

# Clean a specific directory
clean-dev-dirs ~/Projects

# Preview what would be cleaned (dry run)
clean-dev-dirs --dry-run

# Interactive mode - choose which projects to clean
clean-dev-dirs --interactive

Filtering Options

# Only clean projects larger than 100MB
clean-dev-dirs --keep-size 100MB

# Only clean projects not modified in the last 30 days
clean-dev-dirs --keep-days 30

# Clean only Rust projects
clean-dev-dirs --rust-only

# Clean only Node.js projects
clean-dev-dirs --node-only

Advanced Options

# Use 8 threads for scanning
clean-dev-dirs --threads 8

# Show verbose output including scan errors
clean-dev-dirs --verbose

# Skip specific directories
clean-dev-dirs --skip node_modules --skip .git

# Non-interactive mode (auto-confirm)
clean-dev-dirs --yes

๐Ÿ“‹ Command Line Options

Option Short Description
--keep-size -s Ignore projects with build dir smaller than specified size
--keep-days -d Ignore projects modified in the last N days
--rust-only Clean only Rust projects
--node-only Clean only Node.js projects
--yes -y Don't ask for confirmation; clean all detected projects
--dry-run List cleanable projects without actually cleaning
--interactive -i Use interactive project selection
--threads -t Number of threads for directory scanning
--verbose -v Show access errors during scanning
--skip Directories to skip during scanning

๐ŸŽฏ Size Formats

The tool supports various size formats:

  • Decimal: 100KB, 1.5MB, 2GB
  • Binary: 100KiB, 1.5MiB, 2GiB
  • Bytes: 1000000

๐Ÿ” Project Detection

The tool automatically detects development projects by looking for:

  • Rust projects: Directories containing both Cargo.toml and target/
  • Node.js projects: Directories containing both package.json and node_modules/

๐Ÿ›ก๏ธ Safety Features

  • Dry-run mode: Preview operations before execution
  • Interactive confirmation: Choose exactly what to clean
  • Intelligent filtering: Skip recently modified or small projects
  • Error handling: Graceful handling of permission errors and inaccessible files

๐ŸŽจ Output

The tool provides colored, human-readable output including:

  • ๐Ÿฆ€ Rust project indicators
  • ๐Ÿ“ฆ Node.js project indicators
  • ๐Ÿ“Š Size statistics in human-readable format
  • โœจ Status messages and progress indicators
  • ๐Ÿงช Dry-run previews

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“„ License

This project is dual-licensed under either:

You may choose either license at your option.

๐Ÿ™ Acknowledgments

  • Built with Clap for CLI argument parsing
  • Uses Rayon for parallel processing
  • Colored output with Colored
  • Progress indicators with Indicatif