Skip to main content

outcome

Function outcome 

Source
pub fn outcome<'v, T>(
    spec: &Spec<'_>,
    argv: &[&'v OsStr],
    parse_from: impl FnOnce(&[&'v OsStr]) -> Result<T, Error<'static, 'v>>,
) -> Outcome<T>
Expand description

What a CLI would do with one command line.

Pass the CLI’s own parse_from — outcome(Ex::spec(), &words.words(), Ex::parse_from) — which is the function item, not a call. Nothing is printed and nothing exits; the page or message the process would have produced comes back in the Outcome.

A CLI whose identity is computed at run time (#[usage(version = …)] and its neighbours) reports its declared spec values here, since the harness has the spec and not the program. Executable views are the same: this is the plain entry point, and a view is selected by argv0 in parse_from_argv.

A failure’s text is whatever the build being tested would print: the clap-shaped message where diagnostics is on, as the facade’s defaults have it, and the compact error where a parser-only build turned the renderer off.