Skip to main content

parse

Function parse 

Source
pub fn parse<P: Parser>(bin_name: &str, args: &[String]) -> Result<P, u8>
Expand description

Parse args (everything after argv[1] from the dispatcher) into P. On success, returns the parsed struct. On error, prints clap’s formatted diagnostic to stdout (for help/version) or stderr (for usage / value errors) and returns the matching sysexits code so the caller can return it.

bin_name is what clap prefixes errors with — usually "mkit <subcommand>" so a user typo like mkit commit --bogus reads cleanly:

error: unexpected argument '--bogus' found
  tip: a similar argument exists: '--all'
usage: mkit commit [OPTIONS]