29 const std::string_view arg_name,
const std::string_view reason
32 std::format(
"Given name [{}] is invalid.\nReason: {}", arg_name, reason)
47 "Required positional argument [{}] cannot be defined after a non-required "
48 "positional argument [{}].",
49 required_arg_name.str(),
50 non_required_arg_name.str()
61 return parsing_failure(std::format(
"Unknown argument [{}].", arg_name));
66 std::format(
"Value for argument [{}] has already been set.", arg_name.str())
74 std::format(
"Cannot parse value `{}` for argument [{}].", value, arg_name.str())
82 "Value `{}` is not a valid choice for argument [{}].", value, arg_name.str()
89 std::format(
"No values parsed for a required argument [{}]", arg_name.str())
96 std::format(
"Failed to deduce the argument for values [{}]",
detail::join(values))
103 if (std::is_lt(ordering))
105 std::format(
"Not enough values provided for optional argument [{}]", arg_name.str())
108 if (std::is_gt(ordering))
110 std::format(
"Too many values provided for optional argument [{}]", arg_name.str())
114 std::format(
"Invalid number of values provided for argument [{}]", arg_name.str())
128 "Invalid value type specified for argument [{}] = {}.",
134 template <
typename Inval
idType>
137 "Invalid value type specified for argument [{}] = {}.",
139 detail::get_demangled_type_name<InvalidType>()
149 return lookup_failure(std::format(
"Argument with given name [{}] not found.", arg_name));
std::string join(const R &range, const std::string_view delimiter=", ")
Joins elements of a range into a single string with a delimiter.
Provides common string utility functions.
Base type for the argument parser functionality errors/exceptions.
argument_parser_exception(const std::string &message)
Structure holding the argument's name.
static invalid_configuration required_after_non_required(const detail::argument_name &required_arg_name, const detail::argument_name &non_required_arg_name) noexcept
Exception type used for invalid configuration of an argument parser or its arguments.
static invalid_configuration argument_name_used(const detail::argument_name &arg_name) noexcept
invalid_configuration(const std::string &message)
static invalid_configuration invalid_argument_name(const std::string_view arg_name, const std::string_view reason) noexcept
Exception type used for element lookup errors.
lookup_failure(const std::string &message)
static lookup_failure argument_not_found(const std::string_view &arg_name) noexcept
Exception type used for errors encountered during the argument parsing operation.
static parsing_failure invalid_value(const detail::argument_name &arg_name, const std::string &value) noexcept
static parsing_failure invalid_nvalues(const detail::argument_name &arg_name, const std::weak_ordering ordering) noexcept
static parsing_failure unknown_argument(const std::string_view arg_name) noexcept
static parsing_failure required_argument_not_parsed(const detail::argument_name &arg_name) noexcept
static parsing_failure invalid_choice(const detail::argument_name &arg_name, const std::string &value) noexcept
parsing_failure(const std::string &message)
static parsing_failure argument_deduction_failure(const std::vector< std::string > &values) noexcept
static parsing_failure value_already_set(const detail::argument_name &arg_name) noexcept
Exception type used for type-related errors.
type_error(const std::string &message)
static type_error invalid_value_type(const detail::argument_name &arg_name, const std::type_info &value_type) noexcept
static type_error invalid_value_type(const detail::argument_name &arg_name) noexcept