pub struct OptionBuilder { /* private fields */ }Expand description
An builder struct for AnpOption.
Implementations§
Source§impl OptionBuilder
impl OptionBuilder
Sourcepub fn option(self, opt: &str) -> Self
pub fn option(self, opt: &str) -> Self
Set the short option name.
The short option name is not necessary to have a single char.
A short option with multiple chars is also valid, like -required.
Sourcepub fn long_option(self, long_opt: &str) -> Self
pub fn long_option(self, long_opt: &str) -> Self
Set the long option name.
Sourcepub fn has_arg(self, has_arg: bool) -> Self
pub fn has_arg(self, has_arg: bool) -> Self
Set whether the option has exactly one argument or no argument.
Also see Self::has_args and Self::number_of_args.
Sourcepub fn has_args(self) -> Self
pub fn has_args(self) -> Self
Set the option to having unlimited number of arguments.
Also see Self::has_arg and Self::number_of_args.
Sourcepub fn number_of_args(self, number_of_args: usize) -> Self
pub fn number_of_args(self, number_of_args: usize) -> Self
Set the option to having exactly number_of_args number of arguments.
Also see Self::has_arg and Self::has_args
Sourcepub fn optional_arg(self, is_optional: bool) -> Self
pub fn optional_arg(self, is_optional: bool) -> Self
Whether argument(s) is optional.
Sourcepub fn required(self, required: bool) -> Self
pub fn required(self, required: bool) -> Self
Whether the option is required to passed to command line.
Sourcepub fn value_separator(self, value_sep: char) -> Self
pub fn value_separator(self, value_sep: char) -> Self
Set the value separator for the option.
For example, when the value separator set to ,, the option value -v=1,2,3
is parsed into three values.