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]
fn positional<N>(name: N, target: &'tar mut SingleTarget) -> ArgDef<'def, 'tar> where
N: Into<Cow<'def, str>>,
[src]
N: Into<Cow<'def, str>>,
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.
fn trail<N>(
name: N,
optional: bool,
target: &'tar mut CollectionTarget
) -> ArgDef<'def, 'tar> where
N: Into<Cow<'def, str>>,
[src]
name: N,
optional: bool,
target: &'tar mut CollectionTarget
) -> ArgDef<'def, 'tar> where
N: Into<Cow<'def, str>>,
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).
fn subcommand<N, F>(name: N, handler: F) -> ArgDef<'def, 'tar> where
N: Into<Cow<'def, str>>,
F: 'static + FnMut(String, &[&str]) -> Result<Option<i32>, ParseError<'def>>,
[src]
N: Into<Cow<'def, str>>,
F: 'static + FnMut(String, &[&str]) -> Result<Option<i32>, ParseError<'def>>,
Defines a subcommand.
Subcommands cannot be mixed with positional (or trail) arguments in the same parse.
fn interrupt<N, F>(name: N, callback: F) -> ArgDef<'def, 'tar> where
N: Into<Cow<'def, str>>,
F: FnMut(Rc<Help<'def>>) + 'static,
[src]
N: Into<Cow<'def, str>>,
F: FnMut(Rc<Help<'def>>) + 'static,
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
.
fn setting<N>(name: N, target: &'tar mut OptionTarget) -> ArgDef<'def, 'tar> where
N: Into<Cow<'def, str>>,
[src]
N: Into<Cow<'def, str>>,
Defines a 'setting'-type argument.
A optional setting that can only be set once.
The target should be an Option
fn flag<N>(name: N, target: &'tar mut bool) -> ArgDef<'def, 'tar> where
N: Into<Cow<'def, str>>,
[src]
N: Into<Cow<'def, str>>,
Defines a 'flag'-type argument.
This will set its target to true, when passed as an argument.
fn count<N>(name: N, target: &'tar mut usize) -> ArgDef<'def, 'tar> where
N: Into<Cow<'def, str>>,
[src]
N: Into<Cow<'def, str>>,
Creates a description of a count
-type argument.
This will count the number of times the flag was passed in the arguments.
fn collect<N>(name: N, target: &'tar mut CollectionTarget) -> ArgDef<'def, 'tar> where
N: Into<Cow<'def, str>>,
[src]
N: Into<Cow<'def, str>>,
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"]`
fn default_help<D: Into<Cow<'static, str>>>(
description: D
) -> ArgDef<'def, 'tar>
[src]
description: D
) -> ArgDef<'def, 'tar>
Creates a default help interrupt for --help
.
fn default_version() -> ArgDef<'def, 'tar>
[src]
Creates a default version interrupt for --version
.
fn short<N>(self, short: N) -> Self where
N: Into<Cow<'def, str>>,
[src]
N: Into<Cow<'def, str>>,
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);
fn param<N>(self, parameter_name: N) -> Self where
N: Into<Cow<'def, str>>,
[src]
N: Into<Cow<'def, str>>,
Sets the name of the parameter for options that take parameters (option
and collect
).
This is only used for help messages.
fn help<N>(self, help: N) -> Self where
N: Into<Cow<'def, str>>,
[src]
N: Into<Cow<'def, str>>,
Adds a help description for this argument.
This is only used for help messages.