| Crates.io | clean-dev-dirs |
| lib.rs | clean-dev-dirs |
| version | 2.0.1 |
| created_at | 2025-05-30 18:21:45.463129+00 |
| updated_at | 2025-05-30 21:23:24.740428+00 |
| description | A fast CLI tool for recursively cleaning Rust target/ and Node.js node_modules/ directories to reclaim disk space |
| homepage | https://github.com/TomPlanche/clean-dev-dirs |
| repository | https://github.com/TomPlanche/clean-dev-dirs |
| max_upload_size | |
| id | 1695497 |
| size | 153,081 |
A fast and efficient CLI tool for recursively cleaning Rust
target/, Node.jsnode_modules/, Python cache, and Govendor/directories to reclaim disk space.
target/), Node.js (node_modules/), Python (cache dirs), and Go (vendor/) build artifactsThis project is inspired by cargo-clean-all, a Rust-specific tool for cleaning cargo projects. I've improved upon the original concept with:
git clone https://github.com/your-username/clean-dev-dirs.git
cd clean-dev-dirs
cargo install --path .
cargo install clean-dev-dirs
# Clean all development directories in the current directory
clean-dev-dirs
# Clean a specific directory
clean-dev-dirs ~/Projects
# Preview what would be cleaned (dry run)
clean-dev-dirs --dry-run
# Interactive mode - choose which projects to clean
clean-dev-dirs --interactive
# Only clean projects larger than 100MB
clean-dev-dirs --keep-size 100MB
# Only clean projects not modified in the last 30 days
clean-dev-dirs --keep-days 30
# Clean only Rust projects
clean-dev-dirs --rust-only
# Clean only Node.js projects
clean-dev-dirs --node-only
# Clean only Python projects
clean-dev-dirs --python-only
# Clean only Go projects
clean-dev-dirs --go-only
# Use 8 threads for scanning
clean-dev-dirs --threads 8
# Show verbose output including scan errors
clean-dev-dirs --verbose
# Skip specific directories
clean-dev-dirs --skip node_modules --skip .git
# Non-interactive mode (auto-confirm)
clean-dev-dirs --yes
| Option | Short | Description |
|---|---|---|
--keep-size |
-s |
Ignore projects with build dir smaller than specified size |
--keep-days |
-d |
Ignore projects modified in the last N days |
--rust-only |
Clean only Rust projects | |
--node-only |
Clean only Node.js projects | |
--python-only |
Clean only Python projects | |
--go-only |
Clean only Go projects | |
--yes |
-y |
Don't ask for confirmation; clean all detected projects |
--dry-run |
List cleanable projects without actually cleaning | |
--interactive |
-i |
Use interactive project selection |
--threads |
-t |
Number of threads for directory scanning |
--verbose |
-v |
Show access errors during scanning |
--skip |
Directories to skip during scanning |
The tool supports various size formats:
100KB, 1.5MB, 2GB100KiB, 1.5MiB, 2GiB1000000The tool automatically detects development projects by looking for:
Cargo.toml and target/package.json and node_modules/requirements.txt, setup.py, pyproject.toml) and cache dirs (__pycache__, .pytest_cache, venv, etc.)go.mod and vendor/The tool provides colored, human-readable output including:
Contributions are welcome! Please feel free to submit a Pull Request.
Want to add support for a new programming language? Here's how to extend clean-dev-dirs:
First, add your language to the ProjectType enum in src/project/project.rs:
#[derive(Clone, PartialEq)]
pub(crate) enum ProjectType {
Rust,
Node,
Python,
Go,
YourLanguage, // Add your language here
}
Don't forget to update the Display implementation to include an appropriate emoji and name.
Update src/cli.rs to add a command-line flag for your language:
struct ProjectTypeArgs {
// ... existing flags ...
/// Clean only YourLanguage projects
#[arg(long, conflicts_with_all = ["rust_only", "node_only", "python_only", "go_only"])]
your_language_only: bool,
}
Also update the ProjectFilter enum and project_filter() method accordingly.
Add detection logic in src/scanner.rs by implementing:
detect_your_language_project() - identifies projects by looking for characteristic filesextract_your_language_project_name() - parses project configuration files to get the namedetect_project() to call your detection methodExample detection criteria:
fn detect_your_language_project(&self, path: &Path, errors: &Arc<Mutex<Vec<String>>>) -> Option<Project> {
let config_file = path.join("your_config.conf"); // Language-specific config file
let build_dir = path.join("build"); // Build/cache directory to clean
if config_file.exists() && build_dir.exists() {
let name = self.extract_your_language_project_name(&config_file, errors);
let build_arts = BuildArtifacts {
path: build_dir,
size: 0, // Will be calculated later
};
return Some(Project::new(
ProjectType::YourLanguage,
path.to_path_buf(),
build_arts,
name,
));
}
None
}
Add any language-specific directories that should be skipped during scanning to the should_scan_entry() method in src/scanner.rs.
Consider these when testing your implementation:
Some languages that would be great additions:
CMakeLists.txt/Makefile + build/ or cmake-build-*/pom.xml/build.gradle + target/ or build/*.csproj/*.sln + bin//obj/composer.json + vendor/Gemfile + vendor/bundle/Package.swift + .build/When submitting your language support:
This project is dual-licensed under either:
You may choose either license at your option.