rs_clean

Crates.iors_clean
lib.rsrs_clean
version0.3.0
created_at2024-08-21 07:58:30.233487+00
updated_at2025-08-26 07:48:06.345804+00
descriptionRust project that provides a command-line tool designed for cleaning up build artifacts within projects.
homepage
repositoryhttps://github.com/pwh-pwh/rs_clean
max_upload_size
id1346244
size93,758
coderpwh (pwh-pwh)

documentation

README

🧹 rs_clean – Clean Build Targets for Rust, Go, Gradle, and Maven

⚑ Easily remove compiled build artifacts from Rust, Go, Gradle, and Maven projects with a single command.

πŸ“˜ Looking for Chinese docs? View δΈ­ζ–‡θ―΄ζ˜Ž πŸ‡¨πŸ‡³


πŸ—οΈ Architecture Overview

graph TD
    A[rs_clean CLI] --> B{main.rs};
    B --> C(Command Line Argument Parsing: clap);
    C --> D(Initialize Cleaning Commands: constant.rs, utils.rs);
    D -- Supported Commands --> E[lib.rs - do_clean_all];
    E -- Recursive Scan --> F(walkdir);
    F -- Project Identification & Task Generation --> G{cmd.rs - Cmd};
    G -- Asynchronous Execution & Concurrency Control --> H(tokio, Semaphore, futures::join_all);
    H -- Actual Cleaning Operation --> I(Cmd::run_clean);
    I -- External Command Execution --> J(tokio::process::Command);
    I -- node_modules Deletion --> K(tokio::fs::remove_dir_all);
    E -- Result Statistics & Formatting --> L(get_dir_size_async, format_size);
    L -- Progress Display & Final Report --> M(indicatif, colored);

πŸš€ Quick Start

$ rs_clean folder/

This command recursively removes build directories in the specified folder and its subdirectories.

You can also exclude specific directory names from cleaning:

$ rs_clean folder/ --exclude-dir node_modules --exclude-dir build

Or exclude certain project types:

$ rs_clean folder/ --exclude-type go --exclude-type maven

πŸ“¦ Installation

Option 1: Install via Cargo

cargo install rs_clean

Option 2: Download from Releases

πŸ‘‰ Download from GitHub Releases Grab the latest binary for your operating system.


✨ Features

  • βœ… Cleans Rust projects: target/
  • βœ… Cleans Go build output
  • βœ… Cleans Gradle projects: build/
  • βœ… Cleans Maven projects: target/
  • βœ… Cleans Node.js projects: node_modules/ (by removing node_modules directory directly)
  • βœ… Cleans Python projects: __pycache__/, venv/, .venv/, build/, dist/, .eggs/, etc. (by removing these directories directly)
  • βœ… Recursively scans subdirectories
  • βœ… Automatically detects project type
  • βœ… Efficient Parallel Processing: Utilizes asynchronous operations and CPU core awareness for fast, concurrent cleaning.
  • βœ… Safety Mechanisms: Includes limits on directory depth and file count to prevent excessive resource consumption.
  • βœ… Disk Space Reporting: Shows the total disk space freed after cleanup.

πŸ“‚ Example Structure

$ tree my_projects/
my_projects/
β”œβ”€β”€ rust_app/
β”‚   └── target/
β”œβ”€β”€ go_service/
β”‚   └── bin/
β”œβ”€β”€ gradle_app/
β”‚   └── build/
└── maven_module/
    └── target/

After running:

$ rs_clean my_projects/

The build artifacts will be cleaned:

$ tree my_projects/
my_projects/
β”œβ”€β”€ rust_app/
β”œβ”€β”€ go_service/
β”œβ”€β”€ gradle_app/
└── maven_module/

πŸ’‘ Use Cases

  • Free up disk space by removing large build folders.
  • Ensure a clean build environment in CI/CD pipelines.
  • Clean multiple types of projects in monorepos.

πŸ›  Roadmap

  • Add interactive confirmation prompts
  • More detailed disk space reporting per project
  • Customizable exclusion lists for specific directories/files (partially implemented with --exclude-dir)

🀝 Contributing

We welcome contributions and feedback!

  • Open an issue for bugs or suggestions
  • Submit a pull request for enhancements
  • Star ⭐ the repo if you find it helpful

πŸ“„ License

MIT License Β© 2025 [coderpwh]

Commit count: 106

cargo fmt