Skip to main content

render_failure

Function render_failure 

Source
pub fn render_failure(
    spec: &Spec<'_>,
    argv: &[&OsStr],
    error: &Error<'_, '_>,
) -> String
Expand description

What a caller should print for a parse failure, and what to exit with.

The one entry point a generated parse() reaches for, and the reason it exists here rather than in the derive: whether the good rendering is available is a feature of this crate in the adopter’s dependency graph, and a #[cfg] written into generated code is evaluated in the adopter’s crate, where the feature is not theirs to see. That is how a metadata field once got silently dropped; the answer is that the cfg lives beside the thing it gates.

With diagnostics on, this is the clap-shaped message. Without it, the error’s Debug form — which is still better than nothing and is what a parser-only build asked for.

Error::Help and Error::Version are not failures and must be handled before this.