Skip to content

cargo run -p should list valid packages like --bin lists targets #8591

@ralfbiedert

Description

@ralfbiedert

Describe the problem you are trying to solve
We have a virtual workspace with multiple sub-projects and tools (a workspace containing an app we need during development). Before introducing features we got used to running cargo run --bin, which would then print:

error: "--bin" takes one argument.
Available binaries:
    tool_a
    tool_b
    tool_c
    ...

Since tools get refactored a lot it was a nice way of seeing all options without too much ceremony. However, after adding features, running cargo run --bin xxx does not reliably produce the desired target anymore, but cargo run -p xxx does, so we tried switching to that one.

However, running cargo bin -p gives:

error: The argument '--package <SPEC>' requires a value but none was supplied

USAGE:
    cargo.exe run --package <SPEC>

For more information try --help

Describe the solution you'd like
It would be nice if cargo bin -p lists all projects it can currently run, similar to how --bin works.

Notes
I don't know if -p is more powerful than --bin in the sense that it accepts binaries outside the virtual workspace. In that case it would be nice to still list all local ones, and maybe note that other targets could be available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cargo-targetsArea: selection and definition of targets (lib, bins, examples, tests, benches)A-cliArea: Command-line interface, option parsing, etc.A-diagnosticsArea: Error and warning messages generated by Cargo itself.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