Skip to content

Prefix CLI errors with cargo: #15114

Open
@jyn514

Description

@jyn514

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    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`S-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions