kaycxx-cli
C++ CLI library
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
kaycxx::cli::option_base Class Referenceabstract

Common base class for typed options. More...

#include <kaycxx/cli/option.hpp>

Inheritance diagram for kaycxx::cli::option_base:
Inheritance graph
[legend]
Collaboration diagram for kaycxx::cli::option_base:
Collaboration graph
[legend]

Public Member Functions

virtual std::string constvalue_name () const noexcept=0
 Returns the value placeholder name.
 
virtual std::optional< std::any > default_value () const =0
 Returns the configured default value.
 
bool is_repeatable () const noexcept
 Checks whether this option accepts multiple occurrences.
 
 switch_base (std::string_view name, std::optional< std::string_view > description=std::nullopt)
 Creates a switch without a short alias.
 
 switch_base (std::string_view name, char alias, std::optional< std::string_view > description=std::nullopt)
 Creates a switch with a short alias.
 
- Public Member Functions inherited from kaycxx::cli::switch_base
 switch_base (std::string_view name, std::optional< std::string_view > description=std::nullopt)
 Creates a switch without a short alias.
 
 switch_base (std::string_view name, char alias, std::optional< std::string_view > description=std::nullopt)
 Creates a switch with a short alias.
 
virtual ~switch_base ()=default
 Destroys the switch definition.
 
std::string constname () const noexcept
 Returns the long switch name.
 
std::optional< charalias () const noexcept
 Returns the short switch alias.
 
std::optional< std::string > constdescription () const noexcept
 Returns the switch description.
 
void mark_as_action () noexcept
 Marks this switch as a mutually exclusive command action.
 
bool is_action () const noexcept
 Checks whether this switch is a command action.
 
virtual std::string usage () const =0
 Returns generated help usage for this switch.
 
virtual bool expects_value () const noexcept=0
 Checks whether this switch expects a value.
 

Friends

class command
 

Detailed Description

Common base class for typed options.

Member Function Documentation

◆ 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 >.

◆ 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.

◆ 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
nameLong switch name without the leading --.
aliasShort switch alias without the leading -.
descriptionOptional 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
nameLong switch name without the leading --.
descriptionOptional 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: