Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new formatting control character to cargo tree for the library name. #9659

Closed
nebkor opened this issue Jul 6, 2021 · 0 comments · Fixed by #9663
Closed

Add new formatting control character to cargo tree for the library name. #9659

nebkor opened this issue Jul 6, 2021 · 0 comments · Fixed by #9663
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@nebkor
Copy link
Contributor

nebkor commented Jul 6, 2021

Problem

When examining dependencies with cargo tree, there is no way to print the library name, which can be different from the package name, as seen here, in piston2d-graphics' manifest. A programmer using this in her own code would go:

use graphics;

but graphics would not appear in the output of cargo tree, leading to confusion.

Proposed solution

I propose adding a new formatting control character, {n}, that would print out the library name, which defaults to the package name and of which there can be only one per package.

If I had a project that declared piston2d-graphics as a dependency in its Cargo.toml, and I called cargo tree like cargo tree --format '{p} ({n})', I would expect the output for the line that corresponded to piston2d-graphics to look like:

├── piston2d-graphics v0.56.0 (graphics)

Notes

The currently supported formatting characters are:

{p} — The package name.
{l} — The package license.
{r} — The package repository URL.
{f} — Comma-separated list of package features that are enabled.

If {l} were not already used for the license, I would propose that as the new control character.

@nebkor nebkor added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Jul 6, 2021
@bors bors closed this as completed in 66a6737 Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant