---
title: "ClikaRT::cli::Command"
sidebar_label: "Command"
description: "A node in the command tree. Owns nothing itself (a non-owning handle into the App); declares typed options / positionals / flags / subcommands."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--class">class</span>

**Header:** `ClikaRT/cli/command.h`  
**Inherited by:** [`ClikaRT::cli::App`](./App.md)

A node in the command tree. Owns nothing itself (a non-owning handle into the [`App`](./App.md)); declares typed options / positionals / flags / subcommands. Options declared on an ancestor resolve from any descendant.

## Member functions

### add(string\_view, ArgType) {#add}

<div class="api-signature">

[`Arg`](./Arg.md) **`add`**(`std::string_view` `name`, [`ArgType`](./index.md#ArgType) `type`)

</div>

A value option (`--name [-n]`), typed by `type`.

<div class="api-declared">

Declared in `ClikaRT/cli/command.h`, line 74

</div>

### add(string\_view, string\_view, ArgType) {#add-2}

<div class="api-signature">

[`Arg`](./Arg.md) **`add`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::string_view` `long_name`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::string_view` `short_name`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ArgType`](./index.md#ArgType) `type`<br />
)

</div>

Same as `add(name, type)`, with long + short spellings (`--`[`device`](../device-namespace/index.md), `-d`).

<div class="api-declared">

Declared in `ClikaRT/cli/command.h`, line 76

</div>

### positional() {#positional}

<div class="api-signature">

[`Arg`](./Arg.md) **`positional`**(`std::string_view` `name`, [`ArgType`](./index.md#ArgType) `type`)

</div>

A positional argument (matched by position), typed by `type`.

<div class="api-declared">

Declared in `ClikaRT/cli/command.h`, line 78

</div>

### flag(string\_view) {#flag}

<div class="api-signature">

[`Flag`](./Flag.md) **`flag`**(`std::string_view` `name`)

</div>

A boolean switch.

<div class="api-declared">

Declared in `ClikaRT/cli/command.h`, line 80

</div>

### flag(string\_view, string\_view) {#flag-2}

<div class="api-signature">

[`Flag`](./Flag.md) **`flag`**(`std::string_view` `long_name`, `std::string_view` `short_name`)

</div>

Same as `flag(name)`, with long + short spellings.

<div class="api-declared">

Declared in `ClikaRT/cli/command.h`, line 82

</div>

### command() {#command}

<div class="api-signature">

[`Command`](./Command.md) **`command`**(`std::string_view` `name`, `std::string_view` `help` `=` `{}`)

</div>

A subcommand. Registers `name` (its `help` line rides the listing); returns the subcommand's own builder.

<div class="api-declared">

Declared in `ClikaRT/cli/command.h`, line 87

</div>

### alias() {#alias}

<div class="api-signature">

[`Command`](./Command.md)`&` **`alias`**(`std::string_view` `name`)

</div>

add an alias for THIS command

<div class="api-declared">

Declared in `ClikaRT/cli/command.h`, line 88

</div>

### hidden() {#hidden}

<div class="api-signature">

[`Command`](./Command.md)`&` **`hidden`**(`bool` `v` `=` `true`)

</div>

Hide THIS command from help text and completion scripts. It still parses and dispatches by name; hidden governs advertisement only, for verbs an application surfaces through a contextual help of its own.

<div class="api-declared">

Declared in `ClikaRT/cli/command.h`, line 92

</div>

### handler() {#handler}

<div class="api-signature">

[`Command`](./Command.md)`&` **`handler`**([`CommandHandler`](./index.md#CommandHandler) `fn`)

</div>

The handler [`App::run`](./App.md#run) dispatches to when THIS command matches. A throwing handler is contained caller-side (see detail::contain) and becomes the run's failure result. An empty handler clears the one set before: [`App::run`](./App.md#run) then shows the help of a command that has subcommands and returns 0 for one that has none.

<div class="api-declared">

Declared in `ClikaRT/cli/command.h`, line 98

</div>

### group() {#group}

<div class="api-signature">

[`Group`](./Group.md) **`group`**(`std::string_view` `title`)

</div>

A display-only help section; options added through it parse identically.

<div class="api-declared">

Declared in `ClikaRT/cli/command.h`, line 101

</div>

### exclusive() {#exclusive}

<div class="api-signature">

[`ExclusiveGroup`](./ExclusiveGroup.md) **`exclusive`**(`bool` `required` `=` `false`)

</div>

A mutually-exclusive constraint: at most one member (exactly one if required).

<div class="api-declared">

Declared in `ClikaRT/cli/command.h`, line 103

</div>

## Protected member functions

### Command() {#Command}

<div class="api-signature">

**`Command`**() `=default`

</div>

<div class="api-declared">

Declared in `ClikaRT/cli/command.h`, line 107

</div>

## Protected data members

### node\_ {#node_}

<div class="api-signature">

`detail::CmdNode*` **`node_`** `= nullptr`

</div>

<div class="api-declared">

Declared in `ClikaRT/cli/command.h`, line 111

</div>
