Home / Function/ get_command() — flask Function Reference

get_command() — flask Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  596bd738_9f64_52c9_9cdc_d6c4ce8f6278["get_command()"]
  ee9fbc8f_42bd_3ef5_a80f_72abfe054c0b["FlaskGroup"]
  596bd738_9f64_52c9_9cdc_d6c4ce8f6278 -->|defined in| ee9fbc8f_42bd_3ef5_a80f_72abfe054c0b
  67dea11c_5c94_6773_8a63_f280d0830338["_load_plugin_commands()"]
  596bd738_9f64_52c9_9cdc_d6c4ce8f6278 -->|calls| 67dea11c_5c94_6773_8a63_f280d0830338
  6cabef6b_f1ce_76af_5916_c4e9a439548c["load_app()"]
  596bd738_9f64_52c9_9cdc_d6c4ce8f6278 -->|calls| 6cabef6b_f1ce_76af_5916_c4e9a439548c
  b7db9b24_d5be_a8c2_55fe_26b8b73ffe93["_get_current_object()"]
  596bd738_9f64_52c9_9cdc_d6c4ce8f6278 -->|calls| b7db9b24_d5be_a8c2_55fe_26b8b73ffe93
  92f86b9d_3382_d2d4_7d8f_03f683ac426b["app_context()"]
  596bd738_9f64_52c9_9cdc_d6c4ce8f6278 -->|calls| 92f86b9d_3382_d2d4_7d8f_03f683ac426b
  style 596bd738_9f64_52c9_9cdc_d6c4ce8f6278 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/flask/cli.py lines 609–634

    def get_command(self, ctx: click.Context, name: str) -> click.Command | None:
        self._load_plugin_commands()
        # Look up built-in and plugin commands, which should be
        # available even if the app fails to load.
        rv = super().get_command(ctx, name)

        if rv is not None:
            return rv

        info = ctx.ensure_object(ScriptInfo)

        # Look up commands provided by the app, showing an error and
        # continuing if the app couldn't be loaded.
        try:
            app = info.load_app()
        except NoAppException as e:
            click.secho(f"Error: {e.format_message()}\n", err=True, fg="red")
            return None

        # Push an app context for the loaded app unless it is already
        # active somehow. This makes the context available to parameter
        # and command callbacks without needing @with_appcontext.
        if not current_app or current_app._get_current_object() is not app:
            ctx.with_resource(app.app_context())

        return app.cli.get_command(ctx, name)

Subdomains

Defined In

Frequently Asked Questions

What does get_command() do?
get_command() is a function in the flask codebase, defined in src/flask/cli.py.
Where is get_command() defined?
get_command() is defined in src/flask/cli.py at line 609.
What does get_command() call?
get_command() calls 4 function(s): _get_current_object, _load_plugin_commands, app_context, load_app.

Analyze Your Own Codebase

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

Try Supermodel Free