Struct args::Args [] [src]

pub struct Args { /* fields omitted */ }

A dead simple implementation of command line argument parsing and validation.

Methods

impl Args
[src]

Creates an empty set of command line options.

Registers an optional flag argument that does not take an argument and defaults to false.

  • short_name - e.g. "h" for a -h option, or "" for none
  • long_name - e.g. "help" for a --help option, or "" for none
  • desc - A description of the flag for the usage message

Generates a combination of the short and verbose usage messages.

Returns a bool indicating whether or not any options are registered.

Returns a bool indicating whether or not a argument is present.

Returns an iterator visiting all key-value pairs in alphabetical order.

Registers an option explicitly.

  • short_name - e.g. "h" for a -h option, or "" for none
  • long_name - e.g. "help" for a --help option, or "" for none
  • desc - A description of the flag for the usage message
  • hint - A hint to be used in place of the argument in the usage message, e.g. "FILE" for a -o FILE option
  • occur - An enum representing whether the option is required or not
  • default - The default value for this option if there should be one

Parses arguments according to the registered options.

Failures

Fails if any errors are encountered during parsing.

Parses arguments directly from the command line according to the registered options.

Failures

Fails if any errors are encountered during parsing.

Generates a one-line usage summary from the registered options.

Generates a verbose usage summary from the registered options.

Retrieves the optional value of the Opt identified by opt_name, casts it to the type specified by T, runs all provided Validations, and wraps it in an Option.

Failures

See validated_value_of

Retrieves the optional value of the Opt identified by opt_name, casts it to the type specified by T and wraps it in an optional.

Failures

See value_of

Retrieves the value of the Opt identified by opt_name, casts it to the type specified by T and then runs all provided Validations.

Failures

Returns Err(ArgsError) if no Opt correspond to opt_name, if the value cannot be cast to type T or if any validation is considered invalid.

Retrieves the value for the Opt identified by opt_name and casts it to the type specified by T.

Failures

Returns Err(ArgsError) if no Opt corresponds to opt_name or if the value cannot be cast to type T.

Retrieves a vector of values for the Opt identified by opt_name and casts each of them to the type specified by T.

Failures

Returns Err(ArgsError) if no Opt corresponds to opt_name or if any of the values cannot be cast to type T.

Trait Implementations

impl Display for Args
[src]

Formats the value using the given formatter. Read more