20#include <kaycxx/cli/detail/to_string.hpp>
25namespace kaycxx::cli {
32template <parseable_value T>
54 default_value_ = std::move(
value);
63 return std::format(
"<{}>",
name());
72 return default_value_ ? 0 : 1;
96 return *default_value_;
103 return detail::parse_value<T>(
values.front());
111 std::optional<T> default_value_;
Handle for a registered option.
Definition option_handle.hpp:25
Common base class for positional parameter definitions.
Definition parameter_base.hpp:23
std::optional< std::string > const & description() const noexcept
Returns the parameter description.
std::optional< std::string > const & default_value_text() const noexcept
Returns the configured default value rendered for help output.
std::string const & name() const noexcept
Returns the parameter name.
Typed single positional parameter definition.
Definition parameter.hpp:33
void default_value(T value)
Sets the default parameter value.
Definition parameter.hpp:52
std::string usage() const override
Returns generated help usage for this parameter.
Definition parameter.hpp:62
std::size_t max_count() const noexcept override
Returns the maximum number of values consumed by this parameter.
Definition parameter.hpp:80
std::any parse_values(std::span< std::string_view const > values) const override
Parses this positional parameter.
Definition parameter.hpp:93
parameter(std::string_view name, std::optional< std::string_view > description=std::nullopt)
Creates a positional parameter definition.
Definition parameter.hpp:41
std::size_t min_count() const noexcept override
Returns the minimum number of values consumed by this parameter.
Definition parameter.hpp:71
Error thrown when command line arguments cannot be parsed.
Definition parse_error.hpp:19
Defines the common base class for positional parameters.
Defines the command line parse error type.
Defines value parsing support used by typed options and positional parameters.