Struct foropts::Arg
[−]
[src]
pub struct Arg<'a, T> { /* fields omitted */ }
A description of an argument, which may be a Boolean flag or carry a parameter.
Parameters
<'a>
– The lifetime of the argument’s action
<T>
– The result type of the argument
Methods
impl<'a, T> Arg<'a, T>
[src]
pub fn flag<F>(thunk: F) -> Self where
F: Fn() -> T + 'a,
[src]
F: Fn() -> T + 'a,
Creates a new Boolean flag whose action is the given thunk.
pub fn str_param<S, F>(name: S, parser: F) -> Self where
S: Into<String>,
F: Fn(&str) -> Result<T> + 'a,
[src]
S: Into<String>,
F: Fn(&str) -> Result<T> + 'a,
Creates a new argument with raw string parameter.
Parameters
<S>
– type converted to String
to name the parameter
<F>
– type of parsing function
name
– the name of the parameter
parser
– the parsing function, which must convert the raw
&str
to a Result<T>
pub fn parsed_param<A, S, F>(name: S, wrapper: F) -> Self where
S: Into<String>,
F: Fn(A) -> T + 'a,
A: FromStr,
A::Err: ToString,
[src]
S: Into<String>,
F: Fn(A) -> T + 'a,
A: FromStr,
A::Err: ToString,
Creates a new argument with a parameter parsed by str::parse
.
Parameters
<A>
– type into which the raw &str
will be automatically parsed
<S>
– type converted to String
to name the parameter
<F>
– type of the wrapping function
name
– the name of the parameter
wrapper
– function applied to successful parsing result to transform A
to T
pub fn short(self, c: char) -> Self
[src]
Sets the short name of the option.
pub fn long<S: Into<String>>(self, s: S) -> Self
[src]
Sets the long name of the option.
pub fn description<S: Into<String>>(self, s: S) -> Self
[src]
Sets the description of the option (for the help message).