AppGroup
This works similar to a regular click :class:~click.Group but it changes the behavior of the :meth:command decorator so that it automatically wraps the functions in :func:with_appcontext.
Methods
command()
@classmethod
def command(
*args: t.Any,
**kwargs: t.Any
) - > t.Callable[[t.Callable[..., t.Any]], click.Command]
This works exactly like the method of the same name on a regular click.Group but it wraps callbacks in with_appcontext unless it's disabled by passing with_appcontext=False.
Parameters
| Name | Type | Description |
|---|---|---|
| *args | t.Any | Positional arguments passed directly to the underlying click.Group.command method. |
| **kwargs | t.Any | Keyword arguments for command configuration; includes 'with_appcontext' to toggle automatic application context wrapping. |
Returns
| Type | Description |
|---|---|
t.Callable[[t.Callable[..., t.Any]], click.Command] | A decorator that converts the decorated function into a click.Command and ensures it runs within the Flask application context. |
group()
@classmethod
def group(
*args: t.Any,
**kwargs: t.Any
) - > t.Callable[[t.Callable[..., t.Any]], click.Group]
This works exactly like the method of the same name on a regular click.Group but it defaults the group class to AppGroup.
Parameters
| Name | Type | Description |
|---|---|---|
| *args | t.Any | Positional arguments passed to the underlying click.Group.group method. |
| **kwargs | t.Any | Keyword arguments for group configuration, where 'cls' defaults to AppGroup if not specified. |
Returns
| Type | Description |
|---|---|
t.Callable[[t.Callable[..., t.Any]], click.Group] | A decorator that converts the decorated function into a nested AppGroup, allowing for hierarchical CLI structures that maintain application context behavior. |