Command
#include <tpau-cpp-kernal/Command.h>
class Command
Base class for command line programs.
It only produces the output files if no errors occurred during processing.
enum Feature
Optional features a subclass can enable.
| VALUE | DESCRIPTION |
|---|---|
OutputFile |
The command creates an output file. This adds the |
DependencyFile |
The command can create a gcc style dependency file. This option requires the This adds the TODO: Implement the tracking of dependencies and the creation of the dependency file. |
constructor Command
Create a command line program with the given options and arguments.
| Command | ( | const std::vector< Commandline::Option > & options, | |
| std::string arguments, | |||
| std::string_view name, | |||
| FlagSet< Feature > features = FlagSet< Feature >{} | ); |
| PARAMETER | DESCRIPTION |
|---|---|
options |
The option definitions for the program. |
arguments |
The argument names for the program. |
name |
The name of the program. |
features |
The features to enable for the program. |
method create_outputvirtual
Create the output files for the command.
If the feature OutputFile is enabled, this method must be implemented by subclasses to create the output files. It will only be called if no errors occurred during processing.
| virtual int create_output | ( | ); |
| RETURNS | DESCRIPTION |
|---|---|
int |
A non-zero value indicates an error occurred during output creation and will be used as the exit code. |
method maximum_argumentsvirtual
Get the maximum number of arguments allowed for the command.
This method can be overridden by subclasses.
| virtual size_t maximum_arguments | ( | ); |
| RETURNS | DESCRIPTION |
|---|---|
size_t |
The maximum number of arguments allowed for the command. The default is the maximum value of size_t, representing unlimited. |
method minimum_argumentsvirtual
Get the minimum number of arguments required for the command.
This method can be overridden by subclasses.
| virtual size_t minimum_arguments | ( | ); |
| RETURNS | DESCRIPTION |
|---|---|
size_t |
The minimum number of arguments required for the command. The default is 0. |
method processvirtual
Process the command line arguments and options.
This method must be implemented by subclasses to perform the actual processing of the command.
| virtual int process | ( | ) | = 0; |
| RETURNS | DESCRIPTION |
|---|---|
int |
A non-zero value indicates an error occurred during processing and will be used as the exit code. |
method run
Run the command line program with the given arguments.
| int run | ( | int argc, | |
| char *const argv | ); |
| PARAMETER | DESCRIPTION |
|---|---|
argc |
The number of arguments. |
argv |
The arguments. |
| RETURNS | DESCRIPTION |
|---|---|
int |
The exit code of the program. |
member arguments
The parsed command line arguments and options.
member commandline
The command line parser for the command.
member dependency_file
The name of the dependency file.
member features
The features enabled for the command.
member output_file
The name of the output file.
member program_name
The name of the program.