|
ChainCLI
A modern C++20 command-line interface library
|
Represents option arguments in the CLI. More...
#include <option_argument.h>
Public Member Functions | |
| OptionArgument (std::string_view name, std::string_view valueName, std::string_view shortName="", std::string_view optionsComment="", bool required=false, bool repeatable=false) | |
| Construct a new Option Argument object. | |
| std::any | parseToValue (const std::string &input) const override |
| Parse the input string to the argument's value type. | |
| OptionArgument< T > & | withOptionsComment (std::string_view comment) |
| Set the options comment for the argument. | |
| OptionArgument< T > & | withRequired (bool req) |
| Set whether the argument is required. | |
| OptionArgument< T > & | withShortName (std::string_view name) |
| Set the short name for the argument. | |
| OptionArgument< T > & | withRepeatable (bool rep) |
| Set whether the argument can be specified multiple times. | |
Public Member Functions inherited from 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) | |
| 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. | |
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. | |
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) | |
Protected Attributes inherited from cli::commands::OptionArgumentBase | |
| 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 |
Represents option arguments in the CLI.
| T | The type of the argument's value. |
|
inlineexplicit |
Construct a new Option Argument object.
| T | The type of the argument's value. |
| name | The name of the argument (usually starts with "--"). |
| valueName | The name of the value for the argument. |
| shortName | The short name for the argument (usually starts with "-"). |
| optionsComment | A comment describing this argument. |
| required | Whether the argument is required. |
| repeatable | Whether the argument can be specified multiple times. |
|
inlineoverridevirtual |
Parse the input string to the argument's value type.
| input | The input string to parse. |
Implements cli::commands::TypedArgumentBase.
|
inline |
Set the options comment for the argument.
The options comment is a brief description of the argument's purpose, used in help messages and documentation.
| comment | The options comment to set. |
|
inline |
Set whether the argument can be specified multiple times.
| rep | Whether the argument can be specified multiple times. |
|
inline |
Set whether the argument is required.
| req | Whether the argument should be required. |
|
inline |
Set the short name for the argument.
The short name is a single-character alias for the argument, usually prefixed with a single dash (e.g., "-h" for "--help").
| name | The short name to set. |