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

Untemplated Base class for positional arguments in the CLI. Used to store all positional arguments in a single container. More...

#include <positional_argument.h>

Inheritance diagram for cli::commands::PositionalArgumentBase:
cli::commands::TypedArgumentBase cli::commands::ArgumentBase cli::commands::PositionalArgument< T >

Public Member Functions

 PositionalArgumentBase (std::string_view name, std::string_view optionsComment, bool repeatable, bool required, std::type_index t)
 Construct a new Positional Argument object.
 
std::string getOptionsDocString (const docwriting::DocWriter &writer) const override
 Get the options documentation string for the argument.
 
std::string getArgDocString (const docwriting::DocWriter &writer) const override
 Get the argument documentation string for the argument.
 
- Public Member Functions inherited from cli::commands::TypedArgumentBase
std::type_index getType () const
 Get the type of the argument.
 
virtual std::any parseToValue (const std::string &input) const =0
 Parse the input string to the argument's value type.
 
- Public Member Functions inherited from cli::commands::ArgumentBase
constexpr std::string_view getName () const noexcept
 Get the name of the argument.
 
constexpr std::string_view getOptionComment () const noexcept
 Get the option comment for the argument.
 
constexpr bool isRequired () const noexcept
 Check if the argument is required.
 
constexpr bool isRepeatable () const noexcept
 Check if the argument is repeatable.
 
constexpr ArgumentKind getArgType () const
 Get the type of the argument.
 

Additional Inherited Members

- Protected Member Functions inherited from cli::commands::TypedArgumentBase
 TypedArgumentBase (std::type_index t)
 
- Protected Member Functions inherited from cli::commands::ArgumentBase
 ArgumentBase (std::string_view name, std::string_view optionsComment, ArgumentKind argType, bool repeatable, bool required)
 
- Protected Attributes inherited from cli::commands::TypedArgumentBase
const std::type_index type
 
- Protected Attributes inherited from cli::commands::ArgumentBase
const std::string name
 
std::string optionsComment
 
const ArgumentKind argType
 
bool repeatable {false}
 
bool required {true}
 

Detailed Description

Untemplated Base class for positional arguments in the CLI. Used to store all positional arguments in a single container.

Constructor & Destructor Documentation

◆ PositionalArgumentBase()

cli::commands::PositionalArgumentBase::PositionalArgumentBase ( std::string_view  name,
std::string_view  optionsComment,
bool  repeatable,
bool  required,
std::type_index  t 
)
inline

Construct a new Positional Argument object.

Parameters
nameThe name of the argument.
optionsCommentA comment describing this argument.
repeatableWhether the argument can be specified multiple times.
requiredWhether the argument is required.
tThe type of the argument's value.

Member Function Documentation

◆ getArgDocString()

inline_t std::string cli::commands::PositionalArgumentBase::getArgDocString ( const docwriting::DocWriter writer) const
overridevirtual

Get the argument documentation string for the argument.

This string is used in the Usage section of the help message for a command and displays a textual representation of the arguments attributes (e.g. if it is required or repeatable, ...).

Parameters
writerThe documentation writer to use.
Returns
The argument documentation string for the argument.

Implements cli::commands::ArgumentBase.

◆ getOptionsDocString()

inline_t std::string cli::commands::PositionalArgumentBase::getOptionsDocString ( const docwriting::DocWriter writer) const
overridevirtual

Get the options documentation string for the argument.

This string is used in the Options section of the help message for a command, where each argument is listed with its description.

Parameters
writerThe documentation writer to use.
Returns
The options documentation string for the argument.

Implements cli::commands::ArgumentBase.


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