cargo-tree
cargo-tree copied to clipboard
Add depth option
Adds the -D <DEPTH>
/--depth <DEPTH>
option.
Closes #60
Example:
❯ cargo tree -D 1
cargo-tree v0.27.0 (~/Developer/cargo-tree)
├── cargo v0.39.0
├── env_logger v0.7.0
├── failure v0.1.5
├── petgraph v0.4.13
└── structopt v0.3.2
Things to consider:
- This PR is technically a breaking change because now dependencies are truncated if they are farther down the dependency tree instead of if they were already printed, i.e. deciding if we should truncate a dependency is breadth first. Technically the dependencies are still actually printed depth first but I thought it was pretty weird to have deps printing out that were deeper than the specified limit, only to have a
*
printed later on. This might lead to confusing behavior when used with the--duplicate
option though? - Right now this treats packages specified by
--package
as the "root" package, i.e. instead of erroring:
becausecargo tree -D1 -p syn:0.15.44 rror: package syn v0.15.44 not found
syn
is a transitive dependency with a depth>1
, it prints out the dependencies ofsyn
that have a depth<=1
fromsyn
(not the real package root):
Is this the desired behavior?yn v0.15.44 ── proc-macro2 v0.4.30 ── quote v0.6.13 ── unicode-xid v0.1.0
- Should we print out a
*
when truncating a dependency whose children are not being printed because they are above the--depth
limit and is also a duplicate?
Thanks, I'm looking forward to this! :)
Thanks for working on this @mwilliammyers! What does it do if you set the --depth=1
, and your dependency tree looks like this?
A
|- B
|- C
However, A
, B
, and C
are all in your workspace.
I think the ideal solution to #60 would let you show only dependencies referenced directly in your Cargo.toml
files (ie. the things you've specified, local or remote).
Assuming A
is your "main" (or lib) crate then it would do:
A
|- B
@sfackler if I fix the conflicts with master, is this a feature that you would consider adding?