2 releases
Uses new Rust 2024
new 0.1.1 | Apr 19, 2025 |
---|---|
0.1.0 | Apr 14, 2025 |
#139 in Cargo plugins
82 downloads per month
19KB
358 lines
cargo-easy-dep
A cargo subcommand that simplifies dependency management in Rust workspaces by automatically unifying common dependencies at the workspace level.
Overview
In large Rust workspaces, managing dependencies across multiple crates can become cumbersome. cargo-easy-dep
analyzes your workspace and:
- Identifies dependencies used by multiple workspace members
- Adds these common dependencies to the workspace's
Cargo.toml
- Updates each member's
Cargo.toml
to use the workspace dependency
This approach reduces duplication, simplifies updates, and ensures version consistency across your workspace.
Installation
cargo install cargo-easy-dep
Usage
From your workspace root directory, run:
cargo easy-dep
Options
Options:
-m, --min-occurrences <MIN_OCCURRENCES>
Minimum number of occurrences to consider a dependency common [env: CARGO_EASY_DEP_MIN_OCCURRENCES=] [default: 2]
-w, --workspace-root <WORKSPACE_ROOT>
Path to workspace root (defaults to current directory) [env: CARGO_EASY_DEP_WORKSPACE_ROOT=]
-q, --quiet
Suppress all output [env: CARGO_EASY_DEP_QUIET=]
-h, --help
Print help
-V, --version
Print version
Examples
Basic Usage
# Run from your workspace root
cargo easy-dep
Customize Minimum Occurrences
Consider all dependencies used by workspace members:
cargo easy-dep --min-occurrences 1
Specify Workspace Root
cargo easy-dep --workspace-root /path/to/my/workspace
Silent Mode
cargo easy-dep --quiet
How It Works
- Analyzes your workspace structure using
cargo_metadata
- Counts the occurrences of each dependency across workspace members
- Identifies dependencies used by multiple crates (configurable via
--min-occurrences
) - Updates the root
Cargo.toml
to add these dependencies to the[workspace.dependencies]
section - Updates each member's
Cargo.toml
to useworkspace = true
for these dependencies
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Dependencies
~3–11MB
~110K SLoC