Command Attributes Reference
This page lists every attribute you can set on the #[command] attribute at the top level.
Top-level attributes
| Key | Type | Default | Description |
|---|---|---|---|
help |
string | From doc comment or empty | Short description shown in command listings and per-command help |
details |
string | From doc comment or empty | Long description shown only in --help output |
name |
string | Function name | Override the CLI command name |
aliases |
array of strings | Empty | Alternative names that resolve to this command |
hidden |
bool | false |
Omit from app-level help listing; command remains invocable |
deprecated |
bool | false |
Emit a deprecation warning when the command is invoked |
deprecation_note |
string | Empty | Supplementary message appended to the deprecation warning |
Attribute types
String attributes
String attributes must be string literals:
#[command(
help = "Deploy the application",
details = "Long description here.",
name = "ship",
deprecation_note = "use 'upload' instead",
)]
fn deploy(...) { ... }
Boolean attributes
Boolean attributes must be true or false literals:
#[command(
hidden = true,
deprecated = false,
)]
fn debug(...) { ... }
Array attributes
Array attributes must be arrays of string literals:
#[command(aliases = ["ship", "release", "push"])]
fn deploy(...) { ... }
Doc comment priority
If you provide both a doc comment and an explicit help or details attribute, the explicit attribute takes priority:
#[command(help = "Explicit help wins")]
/// This doc comment help is ignored
fn deploy(...) { ... }
Doc comment splitting
A blank line in a doc comment separates help from details:
#[command]
/// Short help text
///
/// Long details text shown only on --help.
/// Can span multiple paragraphs.
fn deploy(...) { ... }
This is equivalent to:
#[command(
help = "Short help text",
details = "Long details text shown only on --help.\nCan span multiple paragraphs.",
)]
fn deploy(...) { ... }
Behavior notes
Deprecated commands
- Render with the
deprecatedstyle (dim by default) in the app-level command listing - Display a "warning: this command is deprecated" banner in per-command help output
- Print a warning to stderr at runtime before executing
Aliased commands
- Invocable by any registered alias
- Primary command name is always shown in help listings
- Aliases do not appear in the listing
Hidden commands
- Omitted from the command listing
- Remain fully invocable
- Useful for debug or migration commands
Oneshot mode restrictions
When using app!(cmd), the following attributes on the command are forbidden and cause a panic at startup:
| Forbidden attribute | Panic message |
|---|---|
aliases |
"oneshot command must not have aliases" |
name (custom) |
"oneshot command must not have a custom name" |
hidden = true |
"oneshot command must not be hidden" |
deprecated = true |
"oneshot command must not be deprecated" |
Additionally, if more than one #[command] is registered in the binary, app!(cmd) panics with "oneshot mode requires exactly one command".