Home / Function/ command() — flask Function Reference

command() — flask Function Reference

Architecture documentation for the command() function in cli.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  f688268e_280f_36e3_281d_55ae0a492f60["command()"]
  ea63e19e_2fd3_885d_2922_e4101fe8320a["AppGroup"]
  f688268e_280f_36e3_281d_55ae0a492f60 -->|defined in| ea63e19e_2fd3_885d_2922_e4101fe8320a
  7a19d77a_86f4_0e30_0626_5cb2e17c7eae["with_appcontext()"]
  f688268e_280f_36e3_281d_55ae0a492f60 -->|calls| 7a19d77a_86f4_0e30_0626_5cb2e17c7eae
  style f688268e_280f_36e3_281d_55ae0a492f60 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/flask/cli.py lines 413–427

    def command(  # type: ignore[override]
        self, *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
        :class:`click.Group` but it wraps callbacks in :func:`with_appcontext`
        unless it's disabled by passing ``with_appcontext=False``.
        """
        wrap_for_ctx = kwargs.pop("with_appcontext", True)

        def decorator(f: t.Callable[..., t.Any]) -> click.Command:
            if wrap_for_ctx:
                f = with_appcontext(f)
            return super(AppGroup, self).command(*args, **kwargs)(f)  # type: ignore[no-any-return]

        return decorator

Subdomains

Defined In

Frequently Asked Questions

What does command() do?
command() is a function in the flask codebase, defined in src/flask/cli.py.
Where is command() defined?
command() is defined in src/flask/cli.py at line 413.
What does command() call?
command() calls 1 function(s): with_appcontext.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free