|
kaycxx-cli
C++ CLI library
|
Handle for a registered command. More...
#include <kaycxx/cli/command_handle.hpp>
Public Member Functions | |
| std::string const & | name () const noexcept |
| Returns the command name. | |
| std::optional< std::string > const & | description () const noexcept |
| Returns this command's configured description. | |
| command_handle | command (std::string_view name, std::optional< std::string_view > description=std::nullopt) |
| Registers a child command. | |
| flag_handle | flag (std::string_view name, std::optional< std::string_view > description=std::nullopt) |
| Registers a flag without a short alias. | |
| flag_handle | flag (std::string_view name, char alias, std::optional< std::string_view > description=std::nullopt) |
| Registers a flag with a short alias. | |
| template<parseable_value T> | |
| option_handle< T > | option (std::string_view name, std::string_view value_name, std::optional< std::string_view > description=std::nullopt) |
| Registers an option without a short alias. | |
| template<parseable_value T> | |
| option_handle< T > | option (std::string_view name, char alias, std::string_view value_name, std::optional< std::string_view > description=std::nullopt) |
| Registers an option with a short alias. | |
| template<parseable_value T> | |
| repeatable_option_handle< T > | repeatable_option (std::string_view name, std::string_view value_name, std::optional< std::string_view > description=std::nullopt) |
| Registers a repeatable option without a short alias. | |
| template<parseable_value T> | |
| repeatable_option_handle< T > | repeatable_option (std::string_view name, char alias, std::string_view value_name, std::optional< std::string_view > description=std::nullopt) |
| Registers a repeatable option with a short alias. | |
| template<parseable_value T> | |
| parameter_handle< T > | parameter (std::string_view name, std::optional< std::string_view > description=std::nullopt) |
| Registers a single positional parameter. | |
| template<parseable_value T> | |
| parameters_handle< T > | parameters (std::string_view name, std::optional< std::string_view > description=std::nullopt) |
| Registers a positional parameter list. | |
| args | parse (int argc, char *argv[]) const |
| Parses command-line arguments from this command as the starting command. | |
| int | print_help (std::ostream &out=std::cout) const |
| Writes generated help output. | |
| int | print_version (std::ostream &out=std::cout) const |
| Writes generated version output. | |
Friends | |
| class | args |
| class | command |
Handle for a registered command.
The handle does not own the command definition. It references data owned by the application and remains valid while that application exists.
|
inline |
Registers a child command.
| name | Command name. |
| description | Optional command description used by generated help output. |
| std::invalid_argument | When the name is already registered or this command has positional parameters. |
|
inlinenoexcept |
Returns this command's configured description.
|
inline |
Registers a flag with a short alias.
| name | Long flag name without the leading --. |
| alias | Short flag alias without the leading -. |
| description | Optional human-readable flag description used by generated help output. |
| std::invalid_argument | When the long name or short alias conflicts with a switch on this command, an ancestor, or a descendant. |
|
inline |
Registers a flag without a short alias.
| name | Long flag name without the leading --. |
| description | Optional human-readable flag description used by generated help output. |
| std::invalid_argument | When the long name conflicts with a switch on this command, an ancestor, or a descendant. |
|
inlinenoexcept |
Returns the command name.
|
inline |
Registers an option with a short alias.
| T | Parsed option value type. |
| name | Long option name without the leading --. |
| alias | Short option alias without the leading -. |
| value_name | Placeholder name for the option value used by generated help output. |
| description | Optional human-readable option description used by generated help output. |
| std::invalid_argument | When the long name or short alias conflicts with a switch on this command, an ancestor, or a descendant. |
|
inline |
Registers an option without a short alias.
| T | Parsed option value type. |
| name | Long option name without the leading --. |
| value_name | Placeholder name for the option value used by generated help output. |
| description | Optional human-readable option description used by generated help output. |
| std::invalid_argument | When the long name conflicts with a switch on this command, an ancestor, or a descendant. |
|
inline |
Registers a single positional parameter.
| T | Parsed parameter value type. |
| name | Placeholder name used by generated help output and parse errors. |
| description | Optional human-readable parameter description used by generated help output. |
|
inline |
Registers a positional parameter list.
| T | Parsed parameter value type. |
| name | Placeholder name used by generated help output and parse errors. |
| description | Optional human-readable parameter description used by generated help output. |
Parses command-line arguments from this command as the starting command.
| argc | Argument count as received by main. |
| argv | Argument values as received by main. |
|
inline |
Writes generated help output.
| out | Output stream receiving the generated help text. Defaults to standard output. |
|
inline |
Writes generated version output.
| out | Output stream receiving the generated version text. Defaults to standard output. |
|
inline |
Registers a repeatable option with a short alias.
| T | Parsed option value type. |
| name | Long option name without the leading --. |
| alias | Short option alias without the leading -. |
| value_name | Placeholder name for each option value used by generated help output. |
| description | Optional human-readable option description used by generated help output. |
| std::invalid_argument | When the long name or short alias conflicts with a switch on this command, an ancestor, or a descendant. |
|
inline |
Registers a repeatable option without a short alias.
| T | Parsed option value type. |
| name | Long option name without the leading --. |
| value_name | Placeholder name for each option value used by generated help output. |
| description | Optional human-readable option description used by generated help output. |
| std::invalid_argument | When the long name conflicts with a switch on this command, an ancestor, or a descendant. |