pub struct OptionList { /* private fields */ }Expand description
Represents a collection of CommandOptions.
Implementations§
Source§impl OptionList
impl OptionList
Sourcepub fn add(&mut self, option: CommandOption) -> Result<(), CommandOption>
pub fn add(&mut self, option: CommandOption) -> Result<(), CommandOption>
Adds the specified CommandOption.
§Returns
false if there is an option with the same alias than the provided one.
Sourcepub fn add_or_replace(&mut self, option: CommandOption)
pub fn add_or_replace(&mut self, option: CommandOption)
Adds the specified CommandOption or replace it it already exists,
Sourcepub fn get<S: AsRef<str>>(&self, name_or_alias: S) -> Option<&CommandOption>
pub fn get<S: AsRef<str>>(&self, name_or_alias: S) -> Option<&CommandOption>
Returns the CommandOption with the given name or alias or None
if not found.
Sourcepub fn get_by_name<S: AsRef<str>>(&self, name: S) -> Option<&CommandOption>
pub fn get_by_name<S: AsRef<str>>(&self, name: S) -> Option<&CommandOption>
Returns the CommandOption with the given name or None if not found.
Sourcepub fn get_by_alias<S: AsRef<str>>(&self, alias: S) -> Option<&CommandOption>
pub fn get_by_alias<S: AsRef<str>>(&self, alias: S) -> Option<&CommandOption>
Returns the CommandOption with the given alias or None if not found.
Sourcepub fn convert<T>(&self, option: &str) -> Result<T>
pub fn convert<T>(&self, option: &str) -> Result<T>
Converts the argument value of the given option to the type T or results Err if:
- The option is not found.
- The option takes no arguments.
- The option takes more than 1 argument.
- The argument value parse fail.
Sourcepub fn convert_all<T>(&self, option: &str) -> Result<Vec<T>>
pub fn convert_all<T>(&self, option: &str) -> Result<Vec<T>>
Converts all the argument values of the given option to the type T or results Err if:
- The option is not found.
- The option takes no arguments.
- The option takes more than 1 argument.
- The argument values parse fail.
Sourcepub fn get_arg<S: AsRef<str>>(&self, option: S) -> Option<&Argument>
pub fn get_arg<S: AsRef<str>>(&self, option: S) -> Option<&Argument>
Returns the Argument of the option with the given name or alias or
None if the option cannot be found or have more than 1 argument.
Sourcepub fn get_args<S: AsRef<str>>(&self, option: S) -> Option<&ArgumentList>
pub fn get_args<S: AsRef<str>>(&self, option: S) -> Option<&ArgumentList>
Returns the ArgumentList of the option with the given name or alias, or None
if the option canno tbe found.
Trait Implementations§
Source§impl Clone for OptionList
impl Clone for OptionList
Source§fn clone(&self) -> OptionList
fn clone(&self) -> OptionList
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more