Skip to main content

parse_or_render

Function parse_or_render 

Source
pub fn parse_or_render() -> Result<Cli, i32>
Expand description

Parse argv to a Cli, or render a clap error and return the exit code.

Returns Ok(cli) on a successful parse.

§Errors

Returns Err(exit_code) when the process should exit immediately, after this function has already printed whatever the user should see:

  • Err(0) for --help/--version: clap renders them to stdout (not errors), then we exit cleanly.
  • Err(2) for a clap usage error (missing/invalid argument, unknown flag). This honors --json: when requested, it emits a fez/v1 error envelope on stdout (code usage) instead of clap’s stderr text (issue #52). Without --json, clap’s human-facing rendering is preserved unchanged.