rs_clean 0.3.0

Rust project that provides a command-line tool designed for cleaning up build artifacts within projects.
Documentation
# 🧹 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]