Common base class for typed options.
More...
#include <kaycxx/cli/option.hpp>
|
|
class | command |
| |
|
template<parseable_value T> |
| class | option_handle |
| |
|
template<parseable_value T> |
| class | repeatable_option_handle |
| |
Common base class for typed options.
◆ default_value()
| virtual std::optional< std::any > kaycxx::cli::option_base::default_value |
( |
| ) |
const |
|
pure virtual |
Returns the configured default value.
- Returns
- Default value stored in type-erased form or an empty optional if no default value is configured.
Implemented in kaycxx::cli::option< T >.
◆ default_value_text()
| std::optional< std::string > const & kaycxx::cli::option_base::default_value_text |
( |
| ) |
const |
|
inlinenoexcept |
Returns the configured default value rendered for help output.
- Returns
- Rendered default value or an empty optional if no default value is configured.
◆ is_repeatable()
| bool kaycxx::cli::option_base::is_repeatable |
( |
| ) |
const |
|
inlinenoexcept |
Checks whether this option accepts multiple occurrences.
- Returns
- True when the option is repeatable, false otherwise.
◆ is_required()
| bool kaycxx::cli::option_base::is_required |
( |
| ) |
const |
|
inlinenoexcept |
Checks whether this option must be specified explicitly.
- Returns
- True when the option is required, false otherwise.
◆ mark_as_defaulted()
| void kaycxx::cli::option_base::mark_as_defaulted |
( |
std::string |
text | ) |
|
|
inlineprotected |
Marks this option as having a default value.
- Exceptions
-
| std::invalid_argument | When the option is required. |
◆ switch_base() [1/2]
| kaycxx::cli::switch_base::switch_base |
( |
std::string_view |
name, |
|
|
char |
alias, |
|
|
std::optional< std::string_view > |
description = std::nullopt |
|
) |
| |
|
explicit |
Creates a switch with a short alias.
- Parameters
-
| name | Long switch name without the leading --. |
| alias | Short switch alias without the leading -. |
| description | Optional human-readable description used by generated help output. |
◆ switch_base() [2/2]
| kaycxx::cli::switch_base::switch_base |
( |
std::string_view |
name, |
|
|
std::optional< std::string_view > |
description = std::nullopt |
|
) |
| |
|
explicit |
Creates a switch without a short alias.
- Parameters
-
| name | Long switch name without the leading --. |
| description | Optional human-readable description used by generated help output. |
◆ value_name()
| virtual std::string const & kaycxx::cli::option_base::value_name |
( |
| ) |
const |
|
pure virtualnoexcept |
Returns the value placeholder name.
- Returns
- Placeholder name used by generated help output and parse errors.
Implemented in kaycxx::cli::option< T >.
The documentation for this class was generated from the following file: