Ookii.CommandLine for C++
2.0.0
|
Abstract base class for subcommands that do their own argument parsing. More...
#include <ookii/subcommand.h>
Public Types | |
using | command_manager_type = basic_command_manager< CharType, Traits, Alloc > |
The concrete type of basic_command_manager used. | |
using | usage_writer_type = basic_usage_writer< CharType, Traits, Alloc > |
The concrete type of basic_usage_writer used. | |
Public Types inherited from ookii::basic_command< CharType, std::char_traits< CharType >, std::allocator< CharType > > | |
using | builder_type = basic_parser_builder< CharType, std::char_traits< CharType >, std::allocator< CharType > > |
The concrete type of basic_parser_builder used. | |
Public Member Functions | |
virtual bool | parse (std::span< const CharType *const > args, const command_manager_type &manager, usage_writer_type *usage)=0 |
Parses the arguments for the command. More... | |
Public Member Functions inherited from ookii::basic_command< CharType, std::char_traits< CharType >, std::allocator< CharType > > | |
basic_command ()=default | |
Initializes a new instance of the basic_command class. | |
basic_command (builder_type &) | |
Initializes a new instance of the basic_command class. More... | |
virtual | ~basic_command ()=default |
Default destructor. | |
virtual int | run ()=0 |
Runs the command, after argument parsing was successful. More... | |
Abstract base class for subcommands that do their own argument parsing.
CharType | The character type used for arguments and other strings. |
Traits | The character traits to use for strings. Defaults to std::char_traits<CharType> . |
Alloc | The allocator to use for strings. Defaults to std::allocator<CharType> . |
Unlike commands that derive directly from the basic_command class, commands that derive from the basic_command_with_custom_parsing class are not created with the basic_command_line_parser class. Instead, they must have a public constructor with no parameters, and must parse the arguments manually by implementing the parse() method.
Several typedefs for common character types are provided:
Type | Definition |
---|---|
ookii::command_with_custom_parsing | ookii::basic_command_with_custom_parsing<char> |
ookii::wcommand_with_custom_parsing | ookii::basic_command_with_custom_parsing<wchar_t> |
|
pure virtual |
Parses the arguments for the command.
args | A span containing the arguments for the command. |
manager | The command manager this command was created with. |
usage | The usage writer that was passed to basic_command_manager::create_command(). |
true
if parsing was successful; otherwise, false
.