Expand description
§cargo-shear
A tool for detecting and removing unused dependencies from Rust projects.
§Overview
cargo-shear analyzes your Rust codebase to identify dependencies that are declared
in Cargo.toml but never actually used in the code. It can automatically remove
these unused dependencies with the --fix flag.
§Architecture
The codebase is organized into several focused modules:
cargo_toml_editor- Handles modifications to Cargo.toml filespackage_analyzer- Analyzes packages to find issuespackage_processor- Processes packages and detects unused dependenciessource_parser- Parses Rust source to extract data
§Usage
use cargo_shear::{CargoShear, CargoShearOptions};
let options = CargoShearOptions::new_for_test(
std::path::PathBuf::from("."),
false, // fix
);
let exit_code = CargoShear::new(std::io::stdout(), options).run();Modules§
Structs§
- Cargo
Shear - The main struct that orchestrates the dependency analysis and removal process.
- Cargo
Shear Options - Command-line options for cargo-shear.
Enums§
- Color
Mode - Color mode for output.
- Output
Format - Output format for cargo-shear.