Skip to content

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

Closed
@nebkor

Description

@nebkor

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions