25#include "parsing/parser_utils.h"
27namespace cli::commands
44 bool required, std::type_index t, std::string_view shortName,
45 std::string_view valueName)
47 ArgumentBase(name, optionsComment, ArgumentKind::Option, repeatable, required),
55 [[nodiscard]]
constexpr std::string_view getValueName() const noexcept {
return valueName; }
58 const std::string valueName;
76 std::string_view shortName =
"", std::string_view optionsComment =
"",
77 bool required =
false,
bool repeatable =
false)
83 [[nodiscard]] std::any
parseToValue(
const std::string &input)
const override;
85#pragma region ChainingMethods
94 this->optionsComment = comment;
114 this->shortName = name;
131 return cli::parsing::ParseHelper::parse<T>(input);
Base class for command-line arguments.
Definition argument.h:41
Base class for flag-like command-line arguments.
Definition argument.h:129
Untemplated base class for option arguments in the CLI. Used to store all option arguments in a singl...
Definition option_argument.h:33
std::string getOptionsDocString(const docwriting::DocWriter &writer) const override
Get the options documentation string for the argument.
Definition option_argument.cpp:22
std::string getArgDocString(const docwriting::DocWriter &writer) const override
Get the argument documentation string for the argument.
Definition option_argument.cpp:27
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.
Definition option_argument.h:43
Represents option arguments in the CLI.
Definition option_argument.h:64
OptionArgument< T > & withRepeatable(bool rep)
Set whether the argument can be specified multiple times.
Definition option_argument.h:121
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.
Definition option_argument.h:75
OptionArgument< T > & withShortName(std::string_view name)
Set the short name for the argument.
Definition option_argument.h:112
std::any parseToValue(const std::string &input) const override
Parse the input string to the argument's value type.
Definition option_argument.h:129
OptionArgument< T > & withOptionsComment(std::string_view comment)
Set the options comment for the argument.
Definition option_argument.h:92
OptionArgument< T > & withRequired(bool req)
Set whether the argument is required.
Definition option_argument.h:101
Base class for typed command-line arguments.
Definition argument.h:108
Documentation writer for CLI commands. Consists of formatters for commands and arguments.
Definition docwriting.h:34