﻿---
title: Commands
description: Commands are the core of any CLI built with Nullean.Argh. The framework supports three registration forms, all fully supported by the source generator...
url: https://docs-v3-preview.elastic.dev/argh/commands
---

# Commands
Commands are the core of any CLI built with Nullean.Argh. The framework supports three registration forms, all fully supported by the source generator.

## Registration forms

```csharp
app.Map("deploy", DeployHandlers.Run);
app.Map("greet", (string name) => Console.WriteLine($"Hello, {name}!"));
app.Map<StorageHandlers>();
```

<tip>
  With class and method-group registration, XML doc comments on your handler methods flow directly into `--help` output. Lambdas skip that path.
</tip>


## Registration APIs


| API                  | Purpose                                                                                                            |
|----------------------|--------------------------------------------------------------------------------------------------------------------|
| `Map(name, handler)` | Bind a command name to a delegate.                                                                                 |
| `Map<T>()`           | Register every public method on `T` as a command (typically a static class of handlers).                           |
| `MapRoot(handler)`   | Default handler when no subcommand is given (at app root, or inside a `MapNamespace` callback for that namespace). |


## Routing

Flat apps route `app <command> …` while hierarchical apps route `app <namespace> … <command> …`. The generator emits the switch/dispatch tree accordingly.
For programmatic route inspection, `ArghParser.Route(args)` returns a `RouteMatch` (`CommandPath`, `RemainingArgs`) without invoking handlers. This is useful for tests and tooling.

## Next steps

- [Registration](https://docs-v3-preview.elastic.dev/argh/commands/registration) - detailed registration patterns
- [Namespaces](https://docs-v3-preview.elastic.dev/argh/commands/namespaces) - grouping commands under shared paths