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

Prefix CLI errors with cargo: #15114

Open
jyn514 opened this issue Jan 27, 2025 · 1 comment
Open

Prefix CLI errors with cargo: #15114

jyn514 opened this issue Jan 27, 2025 · 1 comment
Labels
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` S-triage Status: This issue is waiting on initial triage.

Comments

@jyn514
Copy link
Member

jyn514 commented Jan 27, 2025

Problem

When using cargo run, it can be hard to distinguish output from cargo and output from the spawned executable, especially if both are using clap. Take for example this error:

$ cargo r --exe
error: unexpected argument '--exe' found

  tip: to pass '--exe' as a value, use '-- --exe'

Usage: run --features <FEATURES> [ARGS]...

For more information, try '--help'.

and compare it to this one:

$ cargo r -- --exe
error: a value is required for '--exe <filename>' but none was supplied

For more information, try '--help'.

both of these look similar, and it is hard to tell what's happening at a glance.

Proposed Solution

Prefix each error: diagnostic with cargo:; the example above would start with cargo: error: unexpected argument '--exe' found

Notes

maybe it sense to do this for everyone upstream in clap instead of just for cargo?

@jyn514 jyn514 added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Jan 27, 2025
@epage
Copy link
Contributor

epage commented Jan 27, 2025

imo the usage in the first example should be what differentiates these. Its missing cargo because of cargo's alias system and thats a bug to fix on its own.

@epage epage added A-diagnostics Area: Error and warning messages generated by Cargo itself. A-cli Area: Command-line interface, option parsing, etc. labels Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants