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

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

Closed
ralfbiedert opened this issue Aug 5, 2020 · 1 comment · Fixed by #8808
Closed

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

ralfbiedert opened this issue Aug 5, 2020 · 1 comment · Fixed by #8808
Labels
A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches) A-cli Area: Command-line interface, option parsing, etc. A-diagnostics Area: Error and warning messages generated by Cargo itself. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@ralfbiedert
Copy link

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.

@ralfbiedert ralfbiedert added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Aug 5, 2020
@ehuss ehuss added A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches) A-cli Area: Command-line interface, option parsing, etc. A-diagnostics Area: Error and warning messages generated by Cargo itself. labels Aug 19, 2020
@pksunkara
Copy link

In the meanwhile, you can use https://github.com/pksunkara/cargo-workspaces#list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches) A-cli Area: Command-line interface, option parsing, etc. A-diagnostics Area: Error and warning messages generated by Cargo itself. 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.

3 participants