Builder for creating command-line command.
More...
#include <command_builder.h>
template<extends_result Result = result_base_t>
class koutil::args::command_builder_t< Result >
Builder for creating command-line command.
Allows adding options, arguments, and subcommands before building the final command_t object.
Example:
.add_argument(
argument_t(
"source",
"Source file"))
.build();
argument_t< result_t > argument_t
Definition command_builder.h:36
command_builder_t(std::string_view name, std::string_view description)
Constructs a builder for a command with name and description.
Definition command_builder.h:43
command_t build() &&
Builds and returns the final command.
Definition command_builder.h:91
Builder for creating command-line options.
Definition option_builder.h:29
◆ 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>
◆ command_builder_t() [1/2]
template<extends_result Result = result_base_t>
Constructs a builder for a command with name and description.
- Parameters
-
| name | Command name. |
| description | Command description. |
◆ command_builder_t() [2/2]
template<extends_result Result = result_base_t>
template<void_handle< std::optional< std::string_view >,
result_t & > Handle>
Constructs a builder for a command with name, description, and handler.
- Template Parameters
-
| Handle | Callable type compatible with void(std::optional<std::string_view>, result_t&). |
- Parameters
-
| name | Command name. |
| description | Command description. |
| handle | Function to execute when the command is invoked. |
◆ add_argument()
template<extends_result Result = result_base_t>
Adds a positional argument to the command.
- Parameters
-
- Returns
- Builder.
◆ add_command()
template<extends_result Result = result_base_t>
Adds a subcommand to the command.
- Parameters
-
| command | Subcommand to add. |
- Returns
- Builder.
◆ add_option()
template<extends_result Result = result_base_t>
Adds an option to the command.
- Parameters
-
- Returns
- Builder.
◆ build()
template<extends_result Result = result_base_t>
Builds and returns the final command.
- Returns
- Constructed command_t object.
◆ m_cmd
template<extends_result Result = result_base_t>
The documentation for this class was generated from the following file: