ChainCLI
A modern C++20 command-line interface library
Loading...
Searching...
No Matches
cli::commands::ArgumentGroup Class Reference

Base class for command-line argument groups. More...

#include <argument_group.h>

Inheritance diagram for cli::commands::ArgumentGroup:
cli::commands::ExclusiveGroup cli::commands::InclusiveGroup

Public Member Functions

template<typename... Args>
requires ((!std::same_as<std::remove_cvref_t<Args>, ArgumentGroup> && ...) && (std::derived_from<std::remove_cvref_t<Args>, ArgumentBase> && ...))
 ArgumentGroup (bool exclusive, bool inclusive, Args &&...args)
 Construct a new ArgumentGroup.
 
const std::vector< std::shared_ptr< ArgumentBase > > & getArguments () const noexcept
 Get the arguments in the group.
 
bool isExclusive () const noexcept
 Check if the group is exclusive.
 
bool isInclusive () const noexcept
 Check if the group is inclusive.
 
bool isRequired () const
 Check if this group is required.
 
void addArgument (const std::shared_ptr< ArgumentBase > &arg)
 Add an argument to the group.
 

Detailed Description

Base class for command-line argument groups.

Constructor & Destructor Documentation

◆ ArgumentGroup()

template<typename... Args>
requires ((!std::same_as<std::remove_cvref_t<Args>, ArgumentGroup> && ...) && (std::derived_from<std::remove_cvref_t<Args>, ArgumentBase> && ...))
cli::commands::ArgumentGroup::ArgumentGroup ( bool  exclusive,
bool  inclusive,
Args &&...  args 
)
inlineexplicit

Construct a new ArgumentGroup.

Template Parameters
...ArgsThe types of the arguments to include in the group.
Parameters
exclusiveWhether the group is exclusive.
inclusiveWhether the group is inclusive.
...argsThe arguments to include in the group.

Member Function Documentation

◆ addArgument()

void cli::commands::ArgumentGroup::addArgument ( const std::shared_ptr< ArgumentBase > &  arg)
inline

Add an argument to the group.

Parameters
argThe argument to add.

◆ getArguments()

const std::vector< std::shared_ptr< ArgumentBase > > & cli::commands::ArgumentGroup::getArguments ( ) const
inlinenoexcept

Get the arguments in the group.

The arguments are returned in the order they were added to the group.

Returns
A const reference to the vector of arguments in the group.

◆ isExclusive()

bool cli::commands::ArgumentGroup::isExclusive ( ) const
inlinenoexcept

Check if the group is exclusive.

An exclusive group means that only one argument in the group can be provided by the user.

Returns
True if the group is exclusive, false otherwise.

◆ isInclusive()

bool cli::commands::ArgumentGroup::isInclusive ( ) const
inlinenoexcept

Check if the group is inclusive.

An inclusive group means that at least one argument in the group must be provided by the user.

Returns
True if the group is inclusive, false otherwise.

◆ isRequired()

inline_t bool cli::commands::ArgumentGroup::isRequired ( ) const

Check if this group is required.

A required group means that for exclusive groups, one of argument in the group must be provided, while for inclusive groups, all arguments must be provided.

Returns
True if the group is required, false otherwise.

The documentation for this class was generated from the following files: