holoscan::CLIParser

Beta
View as Markdown

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 (57777).
  • --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.

#include <holoscan/cli_parser.hpp>

Constructors

CLIParser

holoscan::CLIParser::CLIParser() = defaultholoscan::CLIParser::CLIParser() = default

Construct a new CLIParser object.


Methods

initialize

void holoscan::CLIParser::initialize(
std::string app_description = "",
const 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
std::stringDefaults to ""

The description of the application.

app_version
const std::string &Defaults to "0.0.0"

The version of the application.

parse

std::vector<std::string> & holoscan::CLIParser::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.

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

Parameters

argv
std::vector<std::string> &

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

has_error

bool holoscan::CLIParser::has_error() const

Check if there is an error during parsing.

Returns: true If there is an error during parsing.

options

CLIOptions & holoscan::CLIParser::options()CLIOptions & holoscan::CLIParser::options()

Get the reference of the CLIOptions struct.

Returns: The reference of the CLIOptions struct.


Member variables

NameTypeDescription
app_CLI::AppThe CLI11 application object.
is_initialized_boolThe flag to check if the parser is initialized.
has_error_boolThe flag to check if there is an error during parsing.
options_CLIOptionsThe CLI options.