|
kaycxx-cli
C++ CLI library
|
Common base class for command line switches. More...
#include <kaycxx/cli/switch_base.hpp>

Public Member Functions | |
| 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 const & | name () const noexcept |
| Returns the long switch name. | |
| std::optional< char > | alias () const noexcept |
| Returns the short switch alias. | |
| std::optional< std::string > const & | description () 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. | |
Common base class for command line switches.
A switch is either a flag without a value or an option with a value.
|
explicit |
Creates a switch without a short alias.
| name | Long switch name without the leading --. |
| description | Optional human-readable description used by generated help output. |
|
explicit |
Creates a switch with a short alias.
| name | Long switch name without the leading --. |
| alias | Short switch alias without the leading -. |
| description | Optional human-readable description used by generated help output. |
|
noexcept |
Returns the short switch alias.
- or an empty optional if no alias is configured.
|
noexcept |
Returns the switch description.
Checks whether this switch expects a value.
Implemented in kaycxx::cli::flag, and kaycxx::cli::option< T >.
|
noexcept |
Checks whether this switch is a command action.
|
noexcept |
Returns the long switch name.
--.
|
pure virtual |
Returns generated help usage for this switch.
Implemented in kaycxx::cli::flag, and kaycxx::cli::option< T >.