Skip to main content

parse_or_schema

Function parse_or_schema 

Source
pub fn parse_or_schema<T: FdlArgsTrait>() -> T
Expand description

Intercept --fdl-schema and --help, otherwise parse argv.

  • --fdl-schema anywhere in argv: print the JSON schema to stdout, exit 0.
  • --help / -h anywhere in argv: print help to stdout, exit 0.
  • Otherwise: parse via T::try_parse_from. On parse error (missing required positional, unknown flag, invalid value, …) the error message AND the rendered help are printed to stderr; the binary exits with code 2. Showing help on error keeps <bin> (no args) and <bin> --help consistent for binaries that previously dumped usage on missing-args.