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

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

#include <option_argument.h>

Inheritance diagram for cli::commands::OptionArgumentBase:
cli::commands::TypedArgumentBase cli::commands::ArgumentBase cli::commands::FlaggedArgumentBase cli::commands::OptionArgument< T >

Public Member Functions

 OptionArgumentBase (std::string_view name, std::string_view optionsComment, bool repeatable, bool required, std::type_index t, std::string_view shortName, std::string_view valueName)
 Construct a new Option 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.
 
constexpr std::string_view getValueName () const noexcept
 
- 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.
 
- Public Member Functions inherited from cli::commands::FlaggedArgumentBase
constexpr std::string_view getShortName () const noexcept
 Get the short name of the argument.
 

Protected Attributes

const std::string valueName
 
- 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}
 
- Protected Attributes inherited from cli::commands::FlaggedArgumentBase
std::string shortName
 

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 Member Functions inherited from cli::commands::FlaggedArgumentBase
 FlaggedArgumentBase (std::string_view shortName)
 

Detailed Description

Untemplated base class for option arguments in the CLI. Used to store all option arguments in a single container.

Constructor & Destructor Documentation

◆ OptionArgumentBase()

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

Construct a new Option Argument object.

Parameters
nameThe name of the argument (usually starts with "--").
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.
shortNameThe short name for the argument (usually starts with "-").
valueNameThe name of the value for the argument.

Member Function Documentation

◆ getArgDocString()

inline_t std::string cli::commands::OptionArgumentBase::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::OptionArgumentBase::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: