Struct Group

Source
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

Source

pub fn new( consumer: Box<dyn Fn(&Vec<Value>, &HashMap<&str, Value>)>, description: &str, ) -> Self

Create new group configuration.

Source

pub fn add_argument(self, argument: Descriptor) -> Self

Add an argument to this group.

Source

pub fn get_arguments(&self) -> &Vec<Descriptor>

Get argument descriptors.

Source

pub fn add_option(self, option: Descriptor) -> Self

Add an option to this group.

Source

pub fn get_options(&self) -> &HashMap<Rc<String>, Rc<Descriptor>>

Take ownership of all specified options.

Source

pub fn add_child( self, name: &str, aliases: Option<Vec<&str>>, group: Group, ) -> Self

Add a child group known by the passed name.

Source

pub fn get_aliases_for_group_name( &self, group_name: &String, ) -> Option<&Vec<Rc<String>>>

Get known aliases for the passed group name.

Source

pub fn get_children(&self) -> &HashMap<Rc<String>, Rc<Group>>

Get children of the group.

Source

pub fn get_child_known_for(&self, alias: &str) -> Option<Rc<Group>>

Get a child known for the passed alias (including name).

Source

pub fn get_consumer(&self) -> &Box<dyn Fn(&Vec<Value>, &HashMap<&str, Value>)>

Get the registered function to consume the parsed arguments and options.

Source

pub fn description(&self) -> &String

Get the description of the group.

Auto Trait Implementations§

§

impl Freeze for Group

§

impl !RefUnwindSafe for Group

§

impl !Send for Group

§

impl !Sync for Group

§

impl Unpin for Group

§

impl !UnwindSafe for Group

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.