code: def with_appcontext(f):
      """Wraps a callback so that it's guaranteed to be executed with the
      script's application context.
  
      Custom commands (and their options) registered under ``app.cli`` or
      ``blueprint.cli`` will always have an app context available, this
      decorator is not required in that case.
  
      .. versionchanged:: 2.2
          The app context is active for subcommands as well as the
          decorated callback. The app context is always available to
          ``app.cli`` command and parameter callbacks.
      """
  
      @click.pass_context
      def decorator(__ctx, *args, **kwargs):
          if not current_app:
              app = __ctx.ensure_object(ScriptInfo).load_app()
              __ctx.with_resource(app.app_context())
  
          return __ctx.invoke(f, *args, **kwargs)
  
      return update_wrapper(decorator, f)
  
imports: from __future__ import annotations
  import ast
  import importlib.metadata
  import inspect
  import os
  import platform
  import re
  import sys
  import traceback
  import typing
  from functools import update_wrapper
  from operator import itemgetter
  import click
  from click.core import ParameterSource
  from werkzeug import run_simple
  from werkzeug.serving import is_running_from_reloader
  from werkzeug.utils import import_string
  from .globals import current_app
  from .helpers import get_debug_flag
  from .helpers import get_load_dotenv
label_desc: Use image node_id 7 for calling a global function with example usage: with_appcontext(f) and returns: update_wrapper, __ctx