pub struct OptionGroup { /* private fields */ }Expand description
The OptionGroup is used to specify mutually exclusive options.
§Example
Create option group [-optA | -optB]
use anpcli::{AnpOption, OptionGroup, Options};
let group = OptionGroup::new()
.add_option(AnpOption::builder().option("optA").build().unwrap())
.add_option(AnpOption::builder().option("optB").build().unwrap());
let mut options = Options::new();
options.add_option_group(group);Implementations§
Source§impl OptionGroup
impl OptionGroup
Sourcepub fn new() -> OptionGroup
pub fn new() -> OptionGroup
Create a new OptionGroup.
Sourcepub fn add_option(self, option: AnpOption) -> Self
pub fn add_option(self, option: AnpOption) -> Self
Add an option to the group. If the same option key already exists, it’s a replacement operation.
Sourcepub fn get_names(&self) -> Vec<&str>
pub fn get_names(&self) -> Vec<&str>
Get the keys of all options in the group. The key is short option name if exists, otherwise long option name.
Sourcepub fn get_options(&self) -> Vec<Rc<RefCell<AnpOption>>>
pub fn get_options(&self) -> Vec<Rc<RefCell<AnpOption>>>
Get the owned reference of the options in the group.
Sourcepub fn get_selected(&self) -> Option<&String>
pub fn get_selected(&self) -> Option<&String>
Get selected option key in the group.
Sourcepub fn is_required(&self) -> bool
pub fn is_required(&self) -> bool
Check whether the group is required.
Sourcepub fn set_required(&mut self, required: bool)
pub fn set_required(&mut self, required: bool)
Set whether the group is required.
Trait Implementations§
Source§impl Debug for OptionGroup
impl Debug for OptionGroup
Source§impl Display for OptionGroup
impl Display for OptionGroup
Source§impl Hash for OptionGroup
impl Hash for OptionGroup
Source§impl PartialEq for OptionGroup
impl PartialEq for OptionGroup
impl Eq for OptionGroup
Auto Trait Implementations§
impl Freeze for OptionGroup
impl !RefUnwindSafe for OptionGroup
impl !Send for OptionGroup
impl !Sync for OptionGroup
impl Unpin for OptionGroup
impl !UnwindSafe for OptionGroup
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more