rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.58k stars 2.39k forks source link

Option for `cargo tree` to filter out (non-)workspace members #14420

Open zeichenreihe opened 4 weeks ago

zeichenreihe commented 4 weeks ago

Problem

I'm opening this issue because https://github.com/rust-lang/cargo/issues/8105#issuecomment-1284860085 said to open one if one wanted that feature.

cargo tree allows with --prune to remove dependencies from the list. However, as mentioned in https://github.com/rust-lang/cargo/issues/8105#issuecomment-846336129 it only takes in SPEC, and not the proposed "non-members" or "members".

This would be useful to have, since it would allow easily viewing the dependency tree with only workspace members.

Proposed Solution

The solution would be adding some argument, that would then take the values both, member, and non-member (as mentioned in https://github.com/rust-lang/cargo/issues/8105#issuecomment-846336129).

I have no proposed name yet for the argument.

Notes

At the time of writing, there does not exist any such command, see https://github.com/rust-lang/cargo/blob/ba8b39413c74d08494f94a7542fe79aa636e1661/src/doc/src/commands/cargo-tree.md for the cargo tree documentation at the time of writing.

epage commented 4 weeks ago

This would be useful to have, since it would allow easily viewing the dependency tree with only workspace members.

Could you go into more detail on the use case for this? In what scenarios are you wanting to view a tree of only workspace members?

zeichenreihe commented 4 weeks ago

Scenarios:

I think the latter justifies it even more.

Yes it's currently possible to even get the same result, but this requires listing all the dependencies of all crates with --prune, which is annoying and doesn't scale well.