Skip to main content

group

Attribute Macro group 

Source
#[group]
Expand description

Attribute macro for function-first group definitions.

Supports all #[group(...)] options accepted by the derive macro, plus:

  • commands = [a, b, c] where each entry resolves to <name>_command() (or can be explicit calls)
  • groups = [nested] where each entry resolves to <name>_group() (or can be explicit calls)

§Example

#[click::group(name = "cli", commands = [hello], groups = [admin])]
fn cli(#[option(short, long)] verbose: bool) -> click::Result<()> {
    if verbose { println!("verbose mode"); }
    Ok(())
}

let grp = cli_group();