$ show holmgr/cargo-sweep
cargo-sweep is a Cargo subcommand designed to selectively clean unused build artifacts from Rust project target directories. It operates based on various criteria such as file age, installed Rust toolchains, or target directory size limits, allowing users to reduce disk usage without performing a full 'cargo clean'. The tool is implemented as a standalone Rust binary that integrates with Cargo's metadata system to locate projects and analyze their build artifacts. The architecture centers around a modular design where command-line argument parsing (using clap) feeds into a criterion-based cleaning system. Key components include a sophisticated fingerprinting module that replicates Cargo's internal mechanism for associating build artifacts with specific Rust compiler versions, a timestamp handling system for time-based cleaning, and utility functions for human-readable byte formatting. The tool recursively discovers Cargo projects, evaluates which artifacts to retain based on the selected criterion, and safely removes the rest. Despite its technical sophistication, the project carries a maintenance warning in its README indicating it is currently unmaintained and lacks a dedicated maintainer. This is reflected in outdated dependencies (particularly cargo_metadata at version 0.9 versus the latest 0.18.0) and the project's reliance on the original author for issue triage and pull request reviews. While the code demonstrates strong engineering practices and reusable components, its future viability depends on renewed community stewardship.
The LLM identified 1 files worth highlighting for reuse:
This module implements Cargo's fingerprinting mechanism to identify build artifacts associated with specific Rust toolchains. It includes functions to hash Rust compiler versions in a way compatible with Cargo's internal representation (both pre and post Rust 1.85), parse fingerprint directory names, determine which artifacts are built by given toolchains, and clean up artifacts based on age or toolchain usage. The is_custom_toolchain function demonstrates non-obvious skill in distinguishing between standard and custom Rust toolchains by checking against known patterns (named channels like stable/beta/nightly and versioned toolchains like 1.60.0). This module could be extracted for use in other tools that need to interact with Cargo's build cache.