Struct args::Args [] [src]

pub struct Args { /* fields omitted */ }

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

Methods

impl Args
[src]

[src]

Creates an empty set of command line options.

[src]

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

[src]

Generates a combination of the short and verbose usage messages.

[src]

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

[src]

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

[src]

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

[src]

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

[src]

Parses arguments according to the registered options.

Failures

Fails if any errors are encountered during parsing.

[src]

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

Failures

Fails if any errors are encountered during parsing.

[src]

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

[src]

Generates a verbose usage summary from the registered options.

[src]

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

[src]

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

[src]

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.

[src]

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.

[src]

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.

[src]

Retreives an Option<Opt> for the Opt identified by opt_name

Failures

Returns None if no Opt corresponds to opt_name.

Trait Implementations

impl Display for Args
[src]

[src]

Formats the value using the given formatter. Read more