def enter_shell()

in dev/breeze/src/airflow_breeze/utils/docker_command_utils.py [0:0]


def enter_shell(shell_params: ShellParams, output: Output | None = None) -> RunCommandResult:
    """
    Executes entering shell using the parameters passed as kwargs:

    * checks if docker version is good
    * checks if docker-compose version is good
    * updates kwargs with cached parameters
    * displays ASCIIART and CHEATSHEET unless disabled
    * build ShellParams from the updated kwargs
    * shuts down existing project
    * executes the command to drop the user to Breeze shell
    """
    perform_environment_checks(quiet=shell_params.quiet)
    fix_ownership_using_docker(quiet=shell_params.quiet)
    cleanup_python_generated_files()
    if read_from_cache_file("suppress_asciiart") is None and not shell_params.quiet:
        get_console().print(ASCIIART, style=ASCIIART_STYLE)
    if read_from_cache_file("suppress_cheatsheet") is None and not shell_params.quiet:
        get_console().print(CHEATSHEET, style=CHEATSHEET_STYLE)
    if shell_params.use_airflow_version:
        # in case you use specific version of Airflow, you want to bring airflow down automatically before
        # using it. This prevents the problem that if you have newer DB, airflow will not know how
        # to migrate to it and fail with "Can't locate revision identified by 'xxxx'".
        get_console().print(
            f"[warning]Bringing the project down as {shell_params.use_airflow_version} "
            f"airflow version is used[/]"
        )
        bring_compose_project_down(preserve_volumes=False, shell_params=shell_params)

    if shell_params.restart:
        bring_compose_project_down(preserve_volumes=False, shell_params=shell_params)
    if shell_params.include_mypy_volume:
        create_mypy_volume_if_needed()
    shell_params.print_badge_info()
    cmd = ["docker", "compose"]
    if shell_params.quiet:
        cmd.extend(["--progress", "quiet"])
    if shell_params.project_name:
        cmd.extend(["--project-name", shell_params.project_name])
    cmd.extend(["run", "--service-ports", "--rm"])
    if shell_params.tty == "disabled":
        cmd.append("--no-TTY")
    elif shell_params.tty == "enabled":
        cmd.append("--tty")
    cmd.append("airflow")
    cmd_added = shell_params.command_passed
    if cmd_added is not None:
        cmd.extend(["-c", cmd_added])
    if "arm64" in DOCKER_DEFAULT_PLATFORM:
        if shell_params.backend == "mysql":
            get_console().print("\n[warn]MySQL use MariaDB client binaries on ARM architecture.[/]\n")

    if "openlineage" in shell_params.integration or "all" in shell_params.integration:
        if shell_params.backend != "postgres" or shell_params.postgres_version not in ["12", "13", "14"]:
            get_console().print(
                "\n[error]Only PostgreSQL 12, 13, and 14 are supported "
                "as a backend with OpenLineage integration via Breeze[/]\n"
            )
            sys.exit(1)

    command_result = run_command(
        cmd,
        text=True,
        check=False,
        env=shell_params.env_variables_for_docker_commands,
        output=output,
        output_outside_the_group=True,
    )
    if command_result.returncode == 0:
        return command_result
    get_console().print(f"[red]Error {command_result.returncode} returned[/]")
    if get_verbose():
        get_console().print(command_result.stderr)
    notify_on_unhealthy_backend_container(shell_params.project_name, shell_params.backend, output)
    return command_result