π§Ή 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
This command recursively removes build directories in the specified folder and its subdirectories.
You can also exclude specific directory names from cleaning:
Or exclude certain project types:
π¦ Installation
Option 1: Install via Cargo
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 removingnode_modulesdirectory 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
After running:
The build artifacts will be cleaned:
π‘ 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]