[−][src]Struct cmd_args::Group
A group is a collection of possible CLI options and arguments.
Essentially it provides the context of a action called via CLI.
For example: When calling something like dummy.exe test --flag
then test
is the command context since the action test
should be invoked.
Now --flag
can now be either created on the Root
group or
the test
group.
When options are defined on the root group, they are available to every
child group as well, while options defined on a child group are only available to the
child group and its children.
Methods
impl Group
[src]
pub fn new(
consumer: Box<dyn Fn(&Vec<Value>, &HashMap<&str, Value>)>,
description: &str
) -> Self
[src]
consumer: Box<dyn Fn(&Vec<Value>, &HashMap<&str, Value>)>,
description: &str
) -> Self
Create new group configuration.
pub fn add_argument(self, argument: Descriptor) -> Self
[src]
Add an argument to this group.
pub fn get_arguments(&self) -> &Vec<Descriptor>
[src]
Get argument descriptors.
pub fn add_option(self, option: Descriptor) -> Self
[src]
Add an option to this group.
pub fn get_options(&self) -> &HashMap<Rc<String>, Rc<Descriptor>>
[src]
Take ownership of all specified options.
pub fn add_child(
self,
name: &str,
aliases: Option<Vec<&str>>,
group: Group
) -> Self
[src]
self,
name: &str,
aliases: Option<Vec<&str>>,
group: Group
) -> Self
Add a child group known by the passed name.
pub fn get_aliases_for_group_name(
&self,
group_name: &String
) -> Option<&Vec<Rc<String>>>
[src]
&self,
group_name: &String
) -> Option<&Vec<Rc<String>>>
Get known aliases for the passed group name.
pub fn get_children(&self) -> &HashMap<Rc<String>, Rc<Group>>
[src]
Get children of the group.
pub fn get_child_known_for(&self, alias: &str) -> Option<Rc<Group>>
[src]
Get a child known for the passed alias (including name).
pub fn get_consumer(&self) -> &Box<dyn Fn(&Vec<Value>, &HashMap<&str, Value>)>
[src]
Get the registered function to consume the parsed arguments and options.
pub fn description(&self) -> &String
[src]
Get the description of the group.
Auto Trait Implementations
impl !RefUnwindSafe for Group
impl !Send for Group
impl !Sync for Group
impl Unpin for Group
impl !UnwindSafe for Group
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,