pub struct Arg<'a> {
pub name: &'a str,
pub short: Option<&'a str>,
pub long: Option<&'a str>,
pub about: &'a str,
pub num_values: NumValues,
pub value_name: Option<&'a str>,
pub default: Option<fn() -> Value>,
pub required: bool,
pub value_type: Type,
pub validation: fn(&Value) -> Result<(), String>,
}
Expand description
Struct defining a single arg we can accept
Fields§
§name: &'a str
unique key (per Args) to identify this arg
short: Option<&'a str>
short (single dash, e.g -v) alias to match this arg with @note: if multiple args have the same “short” or “long” name then we have a race condition. We do not check for this but which we use should be considered undefined behaviour
long: Option<&'a str>
long (double dash, e.g –verbose) alias to match this arg with
about: &'a str
info about this arg, used when printing –help
num_values: NumValues
number of parameters this arg accepts. See NumValues for more details
value_name: Option<&'a str>
name for the value of this arg in –help, used when printing –help
default: Option<fn() -> Value>
default value for this arg if it is missing. By default no default is given
required: bool
whether this arg is required
value_type: Type
type for values, if given argparsing will fail if given the wrong type + Error::WrongValueType
validation: fn(&Value) -> Result<(), String>
additional validation for this arg. By default is a noop If this returns Err(String) argparsing will fail with the given string + Error::InvalidValue