Class CLIParser

Holoscan v2.1.0
class CLIParser

CLI Parser class.

This class is used to parse the command line arguments. It uses CLI11 library internally.

The application binary (in C++) or the Python script (in Python) can be executed with various command-line options to run the App Driver and/or the App Worker:

  • --driver: Run the App Driver on the current machine. Can be used together with the --worker option to run both the App Driver and the App Worker on the same machine.

  • --worker: Run the App Worker.

  • --address: The address ([<IPv4 address or hostname>][:<port>]) of the App Driver. If not specified, the App Driver uses the default host address (0.0.0.0) with the default port number (8765).

  • --worker-address: The address ([<IP or hostname>][:<port>]) of the App Worker. If not specified, the App Worker uses the default host address (0.0.0.0) with a randomly chosen port number between 10000 and 32767 that is not currently in use.

  • --fragments: The comma-separated names of the fragments to be executed by the App Worker. If not specified, only one fragment (selected by the App Driver) will be executed. all can be used to run all the fragments.

  • --config: The path to the configuration file. This will override the configuration file path configured in the application code (before run() is called).

If neither --driver nor --worker is specified, the application will run the application without the App Driver and the App Worker, as if the application were running in the single-node without network communication. Connections between fragments are replaced with the standard intra-fragment connections (double-buffered transmitter/receiver) used for operators.

Public Functions

CLIParser() = default

Construct a new CLIParser object.

void initialize(std::string app_description = "", std::string app_version = "0.0.0")

Initialize the CLI Parser.

Set the application description and name and add options/flags for parsing.

Parameters

app_description – The description of the application.

std::vector<std::string> &parse(std::vector<std::string> &argv)

Parse the command line arguments.

Parse the command line arguments and return the remaining arguments. * Note that the provided vector ‘argv’ will be modified.

Parameters

argv – The reference to the vector of strings that contains the command line arguments.

Returns

The reference to the vector of strings that contains the remaining arguments (same as ‘argv’).

bool has_error() const

Check if there is an error during parsing.

Returns

true If there is an error during parsing.

CLIOptions &options()

Get the reference of the CLIOptions struct.

Returns

The reference of the CLIOptions struct.

Protected Attributes

CLI::App app_

The CLI11 application object.

bool is_initialized_ = false

The flag to check if the parser is initialized.

bool has_error_ = false

The flag to check if there is an error during parsing.

CLIOptions options_

The CLI options.

Previous Class BooleanCondition
Next Class Clock
© Copyright 2022-2024, NVIDIA. Last updated on Jun 17, 2024.