25#include "parsing/parser_utils.h"
27namespace cli::commands
43 bool required, std::type_index t)
45 ArgumentBase(name, optionsComment, ArgumentKind::Positional, repeatable, required)
67 bool required =
true,
bool repeatable =
false)
72 [[nodiscard]] std::any
parseToValue(
const std::string &input)
const override;
74#pragma region ChainingMethods
83 optionsComment = comment;
107#pragma endregion ChainingMethods
113 return cli::parsing::ParseHelper::parse<T>(input);
123PositionalArgument<T> &createPositionalArgument(std::string_view
id,
124 std::string_view optionsComment,
bool required,
127 static thread_local PositionalArgument<T> instance(
id, optionsComment, required, repeatable);
Base class for command-line arguments.
Definition argument.h:41
Untemplated Base class for positional arguments in the CLI. Used to store all positional arguments in...
Definition positional_argument.h:34
PositionalArgumentBase(std::string_view name, std::string_view optionsComment, bool repeatable, bool required, std::type_index t)
Construct a new Positional Argument object.
Definition positional_argument.h:42
std::string getArgDocString(const docwriting::DocWriter &writer) const override
Get the argument documentation string for the argument.
Definition positional_argument.cpp:27
std::string getOptionsDocString(const docwriting::DocWriter &writer) const override
Get the options documentation string for the argument.
Definition positional_argument.cpp:22
Represents positional arguments in the CLI.
Definition positional_argument.h:57
PositionalArgument(std::string_view name, std::string_view optionsComment="", bool required=true, bool repeatable=false)
Construct a new Positional Argument object.
Definition positional_argument.h:66
PositionalArgument< T > & withRepeatable(bool rep)
Set whether the argument can be specified multiple times.
Definition positional_argument.h:99
std::any parseToValue(const std::string &input) const override
Parse the input string to the argument's value type.
Definition positional_argument.h:111
PositionalArgument< T > & withOptionsComment(std::string_view comment)
Set the options comment for the argument.
Definition positional_argument.h:81
PositionalArgument< T > & withRequired(bool req)
Set whether the argument is required.
Definition positional_argument.h:90
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