# π§Ή 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 δΈζθ―΄ζ π¨π³](./README_zh.md)
---
## ποΈ Architecture Overview
```mermaid
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
```bash
$ 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:
```bash
$ rs_clean folder/ --exclude-dir node_modules --exclude-dir build
```
Or exclude certain project types:
```bash
$ rs_clean folder/ --exclude-type go --exclude-type maven
```
---
## π¦ Installation
### Option 1: Install via Cargo
```bash
cargo install rs_clean
```
### Option 2: Download from Releases
π [Download from GitHub Releases](https://github.com/pwh-pwh/rs_clean/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
```bash
$ tree my_projects/
my_projects/
βββ rust_app/
β βββ target/
βββ go_service/
β βββ bin/
βββ gradle_app/
β βββ build/
βββ maven_module/
βββ target/
```
After running:
```bash
$ rs_clean my_projects/
```
The build artifacts will be cleaned:
```bash
$ 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](https://github.com/pwh-pwh/rs_clean/issues) for bugs or suggestions
* Submit a pull request for enhancements
* Star β the repo if you find it helpful
---
## π License
MIT License Β© 2025 \[coderpwh]