1#ifndef KOUTIL_ARGS_OPTION_H
2#define KOUTIL_ARGS_OPTION_H
41template <extends_result Result = result_base_t>
class option_t {
53 template <
void_handle<std::optional<std::
string_view>, result_t&> Handle>
61 ,
m_handle(std::forward<Handle>(handle)) { }
131template <extends_result Result>
136 m_handle(value, result);
Represents a command-line option.
Definition option.h:41
handle_t m_handle
Definition option.h:128
std::string_view value_name() const
Gets the display name for the option value.
Definition option.h:103
std::optional< char > m_short_name
Definition option.h:124
bool used() const
Checks if the option has been used.
Definition option.h:73
std::string_view m_value_name
Definition option.h:126
bool m_used
Definition option.h:121
auto short_name() const
Gets the short option name.
Definition option.h:85
bool required() const
Checks if the option is required.
Definition option.h:67
option_t(const option_data_t &data, Handle &&handle)
Constructs an option from data and a handler.
Definition option.h:54
bool m_has_value
Definition option.h:118
std::function< void(std::optional< std::string_view >, result_t &)> handle_t
Type alias for option handler function.
Definition option.h:45
Result result_t
Definition option.h:43
bool m_required
Definition option.h:119
void clear_used()
Clears state.
Definition option.h:115
auto long_name() const
Gets the long option name.
Definition option.h:79
std::string_view description() const
Gets the option description.
Definition option.h:91
void process(std::optional< std::string_view > value, result_t &result)
Processes the option value using the assigned handler.
Definition option.h:132
std::optional< std::string_view > m_long_name
Definition option.h:123
bool has_value() const
Checks if the option expects a value.
Definition option.h:97
std::string_view m_description
Definition option.h:125
Holds metadata for an option.
Definition option.h:22
std::string_view description
Description of the option.
Definition option.h:25
std::optional< char > short_name
Short form name (without "-").
Definition option.h:24
bool has_value
True if the option expects a value.
Definition option.h:27
std::string_view value_name
Name used to represent the option value.
Definition option.h:26
std::optional< std::string_view > long_name
Long form name (without "--").
Definition option.h:23
bool required
True if the option is mandatory.
Definition option.h:28