Struct argonaut::ArgDef [] [src]

pub struct ArgDef<'def, 'tar> { /* fields omitted */ }

The description of an expected argument.

Methods

impl<'def, 'tar> ArgDef<'def, 'tar>
[src]

[src]

Defines a required positional argument.

The target value will be updated after the parse, as long as the parse succeeds and is not interrupted by an interrupt-type argument.

[src]

Defines a 'trail'-type argument.

The trail is a collection of the remaining positional arguments, after all the defined ones have been assigned. The trail can optional or mandatory (0+ or 1+ arguments expected).

[src]

Defines a subcommand.

Subcommands cannot be mixed with positional (or trail) arguments in the same parse.

[src]

Defines an interrupt-type argument.

When the identifier for this argument is passed, the callback is run, and the parsing is interrupted. This is for options that should interrupt the parse when encountered, such as --help and --version.

[src]

Defines a 'setting'-type argument.

A optional setting that can only be set once.

The target should be an Option where T: FromStr + Debug.

[src]

Defines a 'flag'-type argument.

This will set its target to true, when passed as an argument.

[src]

Creates a description of a count-type argument.

This will count the number of times the flag was passed in the arguments.

[src]

Defines a 'collect'-type argument.

The flag can be given multiple times, and each argument to it will be added to a collection variable. (ie: a Vec)

gcc -i foo.h -i bar.h => vec!["foo.h", "bar.h"]`

[src]

Creates a default help interrupt for --help.

[src]

Creates a default version interrupt for --version.

[src]

Adds a short identifier for this option, like -h for --help.

Example

let mut eat_ice_cream = false;
parse(&["-e"], &[
    ArgDef::flag("eat_ice_cream", &mut eat_ice_cream).short("e"),
]).unwrap();
assert_eq!(true, eat_ice_cream);

[src]

Sets the name of the parameter for options that take parameters (option and collect).

This is only used for help messages.

[src]

Adds a help description for this argument.

This is only used for help messages.