> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sdk-user-guide/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/holoscan/sdk-user-guide/_mcp/server.

# holoscan::CLIParser

> CLI Parser class.

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.

```cpp showLineNumbers={false}
#include <holoscan/cli_parser.hpp>
```

---

## Constructors

### CLIParser \[#cliparser]

```cpp showLineNumbers={false}
holoscan::CLIParser::CLIParser() = default
```

Construct a new `CLIParser` object.

---

## Methods

### initialize \[#initialize]

```cpp showLineNumbers={false}
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::string` — default: ""

The description of the application.

---

**`app_version`** `const std::string &` — default: "0.0.0"

The version of the application.

---

### parse \[#parse]

```cpp showLineNumbers={false}
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 \[#haserror]

```cpp showLineNumbers={false}
bool holoscan::CLIParser::has_error() const
```

Check if there is an error during parsing.

**Returns:** true If there is an error during parsing.

### options \[#options]

```cpp showLineNumbers={false}
CLIOptions & holoscan::CLIParser::options()
```

Get the reference of the [CLIOptions](../structs/clioptions) struct.

**Returns:** The reference of the [CLIOptions](../structs/clioptions) struct.

---

## Member variables

| Name              | Type         | Description                                            |
| ----------------- | ------------ | ------------------------------------------------------ |
| `app_`            | `CLI::App`   | The CLI11 application object.                          |
| `is_initialized_` | `bool`       | The flag to check if the parser is initialized.        |
| `has_error_`      | `bool`       | The flag to check if there is an error during parsing. |
| `options_`        | `CLIOptions` | The CLI options.                                       |