Command-line parser.
More...
#include <parser.h>
|
| | parser_t (std::string_view name, std::string_view description) |
| | Constructs a parser with a name and description.
|
| |
| | parser_t (command_t cmd) |
| | Constructs a parser from command.
|
| |
| std::string_view | name () const |
| | Gets the parser name.
|
| |
| std::string_view | description () const |
| | Gets the parser description.
|
| |
| bool | add_command (command_t &&command) |
| | Adds a subcommand.
|
| |
| bool | add_option (const option_t &option) |
| | Adds an option to the parser.
|
| |
| void | add_argument (const argument_t &argument) |
| | Adds a positional argument.
|
| |
| result_t | parse (const char *const *args, std::uint32_t argc) |
| | Parses command-line arguments.
|
| |
| result_t | parse (std::span< const char *const > args) |
| | Parses command-line arguments.
|
| |
| void | show_help (std::ostream &out=std::cout, std::size_t terminal_size=80) const |
| | Displays help text.
|
| |
| void | clear_used () |
| | Clears state.
|
| |
template<extends_result Result = result_base_t>
class koutil::args::parser_t< Result >
Command-line parser.
- Template Parameters
-
◆ argument_t
template<extends_result Result = result_base_t>
◆ command_t
template<extends_result Result = result_base_t>
◆ option_t
template<extends_result Result = result_base_t>
◆ result_t
template<extends_result Result = result_base_t>
◆ parser_t() [1/2]
template<extends_result Result>
Constructs a parser with a name and description.
- Parameters
-
| name | Parser name. |
| description | Parser description. |
◆ parser_t() [2/2]
template<extends_result Result>
Constructs a parser from command.
- Parameters
-
◆ add_argument()
template<extends_result Result>
Adds a positional argument.
- Parameters
-
◆ add_command()
template<extends_result Result>
Adds a subcommand.
- Parameters
-
- Returns
- True if added successfully.
◆ add_option()
template<extends_result Result>
Adds an option to the parser.
- Parameters
-
- Returns
- True if added successfully.
◆ clear_used()
template<extends_result Result = result_base_t>
◆ description()
template<extends_result Result = result_base_t>
Gets the parser description.
- Returns
- Parser description
◆ name()
template<extends_result Result = result_base_t>
Gets the parser name.
- Returns
- Parser name
◆ parse() [1/2]
template<extends_result Result>
Parses command-line arguments.
- Parameters
-
| args | Argument array. |
| argc | Number of arguments. |
- Returns
- Parsing result.
◆ parse() [2/2]
template<extends_result Result>
Parses command-line arguments.
- Parameters
-
- Returns
- Parsing result.
◆ show_help()
template<extends_result Result = result_base_t>
| void koutil::args::parser_t< Result >::show_help |
( |
std::ostream & | out = std::cout, |
|
|
std::size_t | terminal_size = 80 ) const |
|
inline |
Displays help text.
- Parameters
-
| out | Output stream. |
| terminal_size | Width of the terminal. |
◆ m_main_command
template<extends_result Result = result_base_t>
◆ m_version
template<extends_result Result = result_base_t>
The documentation for this class was generated from the following file: