cargo-tree
cargo-tree copied to clipboard
Option to limit tree depth
For example, --depth=2 to only show my dependencies and their direct dependencies.
I wanted to have a quick overview of the direct dependencies of my crate without having to open Cargo.toml. Something akin to what was possible with cargo ls.
An option --depth=1 and maybe aliased to --ls would be super useful.
Yes, please add --depth, and a shortcut -D being equivalent to --depth=1 because this is the most useful.
E.g. to find out which crates in your workspace use different versions of the same dep (assuming you run this in your main crate that depends on all other workspace crates):
cargo tree -d --depth=1 | rg '^\w'
Without --depth=1, it shows duplicates among transitive deps, which you have no control over.