Duplicated "error:" prefix
Please complete the following tasks
- I have searched the discussions
- I have searched the open and rejected issues
Rust Version
rustc 1.79.0-nightly (129f3b996 2024-06-10) (gentoo)
Clap Version
4.5.4
Minimal reproducible code
use std::env::args_os;
use anyhow::Result;
use clap::Parser;
/// Simple program to greet a person
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
/// Name of the person to greet
#[arg(short, long)]
name: String,
}
fn main() -> Result<()> {
let _args = Args::try_parse_from(args_os())?;
Ok(())
}Steps to reproduce the bug with the above code
cargo run
Actual Behaviour
Prints:
Error: error: the following required arguments were not provided:
--name <NAME>
Usage: playground --name <NAME>
For more information, try '--help'.Expected Behaviour
Prints:
Error: the following required arguments were not provided:
--name <NAME>
Usage: playground --name <NAME>
For more information, try '--help'.Additional Context
The "error:" prefix is duplicated. I find this behavior irritating. One prefix seems to be added by the standard library, the other by clap (I don't believe clap is alone with such behavior)
In my opinion the standard library's behavior is questionable -- it's just way too opinionated and this is a good example -- but I wanted to get your guys' take and have an issue to reference to make the case for changing it (which I suppose may be a hard sell irrespectively).
In general, though, it also feels as if just the typical wording of "failed to [...]" or similar would be sufficient for convey the issue. Meaning that there is no need for an "error:" at all, even from the clap side. It just depends too much on the context how the error is reported whether it makes sense to include such a prefix or not.
Any opinions/comments/thoughts?
Debug Output
No response
Source: clap-rs/clap