7 releases
| 0.3.0 | Aug 26, 2025 |
|---|---|
| 0.2.2 | Aug 25, 2025 |
| 0.1.2 | Aug 22, 2024 |
#943 in Command line utilities
321 downloads per month
43KB
802 lines
π§Ή 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 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
$ 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]
Dependencies
~9β16MB
~313K SLoC