#[command]Expand description
Attribute macro for function-first command definitions.
The annotated function parameters must use click parameter attributes such as
#[option(...)] or #[argument(...)]. The macro generates:
- a hidden derive-backed struct that carries the parameter metadata
- a
<function_name>_command()helper that builds aclick::Command
§Example
ⓘ
#[click::command(name = "hello")]
fn hello(#[argument] name: String, #[option(short, long)] loud: bool) -> click::Result<()> {
if loud { println!("HELLO, {}!", name); } else { println!("Hello, {}!", name); }
Ok(())
}
let cmd = hello_command();