69 return "unknown option";
71 return "unknown command";
73 return "unexpected argument";
75 return "missing value";
77 return "invalid value";
79 return "duplicate argument";
81 return "conversion error";
83 return "out of range";
85 return "missing required argument";
87 return "mutually exclusive argument";
89 return "dependency missing";
91 return "invalid choice";
93 return "validation failed";
95 return "help requested";
97 return "exit success";
99 return "unknown error";
102 return "unknown error";
155 [[nodiscard]]
constexpr auto exit_code() const noexcept ->
int {
169 [[nodiscard]]
constexpr auto use_stdout() const noexcept ->
bool {
182 [[nodiscard]]
constexpr auto message() const -> std::
string {
217 [[nodiscard]]
constexpr auto has_error() const noexcept ->
bool {
Actions that convert a raw std::string_view token to a typed value.
Actions that validate a typed value after conversion.
auto parse(int argc, char *argv[]) -> ParseResult< T >
Convenience free function that parses argc/argv into type T.
ErrorKind
Broad classification of an error for structured error handling.
constexpr auto to_string(ErrorCode code) noexcept -> std::string_view
Returns a human-readable description of an ErrorCode.
ErrorCode
Identifies the specific failure that occurred during parsing or validation.
@ invalid_value
A value could not be interpreted as the required type.
@ unknown_option
An unrecognised option name was encountered.
@ conversion_error
Generic failure during string-to-type conversion.
@ unknown_command
An unrecognised subcommand name was encountered.
@ unknown_error
Sentinel/default; indicates no error has been set.
@ out_of_range
A numeric value fell outside the representable range of the target type.
@ duplicate_argument
An option or positional that forbids repetition was seen more than once.
@ validation_failed
A user-defined or built-in validation predicate rejected the value.
@ missing_value
An option that requires a value was given none.
@ invalid_choice
A value was not among the allowed choices.
@ exit_success
The action pipeline requested a clean exit with code 0.
@ help_requested
The --help flag (or equivalent) was seen; print help and exit 0.
@ dependency_missing
An option that depends on another option was given without it.
@ mutually_exclusive
Two mutually-exclusive options were both supplied.
@ missing_required
A required option or positional was not provided.
@ unexpected_argument
A positional argument was supplied when none was expected.
Carries all context about a single parse/validation failure.
ErrorCode code
The specific error code; unknown_error means no error.
std::string subject
The token or option name that caused the error (may be empty).
std::string detail
Additional human-readable context about the failure (may be empty).
constexpr auto exit_code() const noexcept -> int
Returns the process exit code appropriate for this error.
ErrorKind kind
Broad category of the error.
constexpr auto has_position() const noexcept -> bool
Returns true when position contains a valid argv index.
constexpr auto use_stdout() const noexcept -> bool
Returns true when the error message should be written to stdout.
int position
Zero-based index into argv where the error was detected, or -1 if unknown.
constexpr auto has_error() const noexcept -> bool
Returns true when an actual error is present.
constexpr auto message() const -> std::string
Formats a human-readable error message.