|
kaycxx-cli
C++ CLI library
|
Parsed command line arguments. More...
#include <kaycxx/cli/args.hpp>
Public Member Functions | |
| args ()=default | |
| Creates an empty argument collection. | |
| args (args const &)=delete | |
| Prevents copying parsed arguments. | |
| args & | operator= (args const &)=delete |
| Prevents copy-assigning parsed arguments. | |
| args (args &&other) noexcept=default | |
| Moves parsed arguments. | |
| args & | operator= (args &&other) noexcept=default |
| Move-assigns parsed arguments. | |
| void | validate () const |
| Validates required options and subcommands and converts all positional parameters. | |
| command const & | selected_command () const |
| Returns the deepest command selected by the parsed command line. | |
| bool | is_selected (command const &command) const noexcept |
| Checks whether a command is the deepest selected command. | |
| bool | is_selected (command_handle const &command) const noexcept |
| Checks whether a command handle identifies the deepest selected command. | |
| bool | get (flag_handle const &flag) const |
| Checks whether a flag was set. | |
| template<parseable_value T> | |
| T const & | get (option_handle< T > const &option) const |
| Returns a parsed option value. | |
| template<parseable_value T> | |
| bool | has (option_handle< T > const &option) const |
| Checks whether an option value is available. | |
| template<parseable_value T> | |
| std::vector< T > const & | get (repeatable_option_handle< T > const &option) const |
| Returns all parsed values of a repeatable option. | |
| template<parseable_value T> | |
| bool | has (repeatable_option_handle< T > const &option) const |
| Checks whether values for a repeatable option are available. | |
| template<parseable_value T> | |
| T const & | get (parameter_handle< T > const ¶meter) const |
| Returns a parsed positional parameter value. | |
| template<parseable_value T> | |
| bool | has (parameter_handle< T > const ¶meter) const |
| Checks whether a positional parameter value is available. | |
| template<parseable_value T> | |
| std::vector< T > const & | get (parameters_handle< T > const ¶meters) const |
| Returns parsed positional parameter list values. | |
| template<parseable_value T> | |
| bool | has (parameters_handle< T > const ¶meters) const |
| Checks whether positional parameter list values are available. | |
Friends | |
| class | command |
Parsed command line arguments.
Instances are returned directly by command::parse(). Values are queried with the handles returned by command registration methods.
Parsed arguments have unique ownership and can be moved but not copied.
Required options, subcommands and positional parameters are validated lazily when positional values are first accessed or when validate() is called explicitly.
The command that created an instance must outlive it and all handles used to access it.
|
defaultnoexcept |
Moves parsed arguments.
| other | Parsed arguments to move from. |
| bool kaycxx::cli::args::get | ( | flag_handle const & | flag | ) | const |
Checks whether a flag was set.
| flag | Flag handle returned by command::flag(). |
|
inline |
Returns a parsed option value.
| T | Option value type. |
| option | Option handle returned by command::option(). |
|
inline |
Returns a parsed positional parameter value.
| T | Parameter value type. |
| parameter | Parameter handle returned by command::parameter(). |
| parse_error | When positional parameter validation fails. |
|
inline |
Returns parsed positional parameter list values.
| T | Parameter value type. |
| parameters | Parameter list handle returned by command::parameters(). |
| parse_error | When positional parameter validation fails. |
|
inline |
Returns all parsed values of a repeatable option.
| T | Option value type. |
| option | Repeatable option handle returned by command::repeatable_option(). |
|
inline |
Checks whether an option value is available.
| T | Option value type. |
| option | Option handle returned by command::option(). |
|
inline |
Checks whether a positional parameter value is available.
| T | Parameter value type. |
| parameter | Parameter handle returned by command::parameter(). |
| parse_error | When positional parameter validation fails. |
|
inline |
Checks whether positional parameter list values are available.
| T | Parameter value type. |
| parameters | Parameter list handle returned by command::parameters(). |
| parse_error | When positional parameter validation fails. |
|
inline |
Checks whether values for a repeatable option are available.
| T | Option value type. |
| option | Repeatable option handle returned by command::repeatable_option(). |
Checks whether a command is the deepest selected command.
| command | Command to check. |
|
noexcept |
Checks whether a command handle identifies the deepest selected command.
| command | Command handle to check. |
Move-assigns parsed arguments.
| other | Parsed arguments to move from. |
Returns the deepest command selected by the parsed command line.
The application is returned when no subcommand was selected. This allows command actions such as help to inspect the current command before validation reports a missing subcommand.
| std::logic_error | When called on an argument collection that was not returned by command::parse(). |
| void kaycxx::cli::args::validate | ( | ) | const |
Validates required options and subcommands and converts all positional parameters.
Calling this method repeatedly has no effect after the first successful validation.
| parse_error | When a required option, subcommand or positional parameter is missing, an unexpected positional argument is present, or conversion fails. |