pub struct Group { /* private fields */ }
Expand description
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.
Implementations§
Source§impl Group
impl Group
Sourcepub fn new(
consumer: Box<dyn Fn(&Vec<Value>, &HashMap<&str, Value>)>,
description: &str,
) -> Self
pub fn new( consumer: Box<dyn Fn(&Vec<Value>, &HashMap<&str, Value>)>, description: &str, ) -> Self
Create new group configuration.
Sourcepub fn add_argument(self, argument: Descriptor) -> Self
pub fn add_argument(self, argument: Descriptor) -> Self
Add an argument to this group.
Sourcepub fn get_arguments(&self) -> &Vec<Descriptor>
pub fn get_arguments(&self) -> &Vec<Descriptor>
Get argument descriptors.
Sourcepub fn add_option(self, option: Descriptor) -> Self
pub fn add_option(self, option: Descriptor) -> Self
Add an option to this group.
Sourcepub fn get_options(&self) -> &HashMap<Rc<String>, Rc<Descriptor>>
pub fn get_options(&self) -> &HashMap<Rc<String>, Rc<Descriptor>>
Take ownership of all specified options.
Sourcepub fn add_child(
self,
name: &str,
aliases: Option<Vec<&str>>,
group: Group,
) -> Self
pub fn add_child( self, name: &str, aliases: Option<Vec<&str>>, group: Group, ) -> Self
Add a child group known by the passed name.
Sourcepub fn get_aliases_for_group_name(
&self,
group_name: &String,
) -> Option<&Vec<Rc<String>>>
pub fn get_aliases_for_group_name( &self, group_name: &String, ) -> Option<&Vec<Rc<String>>>
Get known aliases for the passed group name.
Sourcepub fn get_child_known_for(&self, alias: &str) -> Option<Rc<Group>>
pub fn get_child_known_for(&self, alias: &str) -> Option<Rc<Group>>
Get a child known for the passed alias (including name).
Sourcepub fn get_consumer(&self) -> &Box<dyn Fn(&Vec<Value>, &HashMap<&str, Value>)>
pub fn get_consumer(&self) -> &Box<dyn Fn(&Vec<Value>, &HashMap<&str, Value>)>
Get the registered function to consume the parsed arguments and options.
Sourcepub fn description(&self) -> &String
pub fn description(&self) -> &String
Get the description of the group.