# Path: valohai_cli/messages.py
# def warn(message: str, err: bool = True) -> None:
#     click.echo(_format_message(message, WARN_EMOJI, 'Warning:', 'yellow'), err=err)


import sys
import click
import requests
import valohai_cli
from typing import Optional
from valohai_cli.messages import warn
        from distutils.version import LooseVersion
    if upgrade_status == 'upgrade':
        click.secho(
            '\nGood news! An upgrade is available!\n'
            'Run (e.g.) `pip install -U valohai-cli` to install the new version.',
            bold=True,
            fg='green',
        )
        click.echo('Upgrade instructions may differ based on the method you\'ve installed the application with.')
        sys.exit(1)
    elif upgrade_status == 'delorean':
        click.secho(
            '\nWhen this thing gets up to 88 mph... You seem to be running a version from the future!\n',
            bold=True,
            fg='cyan',
        )
    elif upgrade_status == 'current':
        click.echo('\nYou seem to be running the latest and greatest. Good on you!')


def determine_upgrade_status(current_version: str, latest_version: str) -> Optional[str]:
    try:
        parsed_current_version = LooseVersion(current_version)
        parsed_latest_version = LooseVersion(latest_version)
        if parsed_latest_version > parsed_current_version:
            return 'upgrade'
        elif parsed_latest_version < parsed_current_version:
            return 'delorean'
        elif parsed_latest_version == parsed_current_version:
            return 'current'
    except Exception as exc:

# Path: valohai_cli/messages.py
# def warn(message: str, err: bool = True) -> None:
#     click.echo(_format_message(message, WARN_EMOJI, 'Warning:', 'yellow'), err=err)


# Path: valohai_cli/commands/update_check.py
import sys
import click
import requests
import valohai_cli
from typing import Optional
from valohai_cli.messages import warn
        from distutils.version import LooseVersion

    if upgrade_status == 'upgrade':
        click.secho(
            '\nGood news! An upgrade is available!\n'
            'Run (e.g.) `pip install -U valohai-cli` to install the new version.',
            bold=True,
            fg='green',
        )
        click.echo('Upgrade instructions may differ based on the method you\'ve installed the application with.')
        sys.exit(1)
    elif upgrade_status == 'delorean':
        click.secho(
            '\nWhen this thing gets up to 88 mph... You seem to be running a version from the future!\n',
            bold=True,
            fg='cyan',
        )
    elif upgrade_status == 'current':
        click.echo('\nYou seem to be running the latest and greatest. Good on you!')


def determine_upgrade_status(current_version: str, latest_version: str) -> Optional[str]:
    try:
        parsed_current_version = LooseVersion(current_version)
        parsed_latest_version = LooseVersion(latest_version)
        if parsed_latest_version > parsed_current_version:
            return 'upgrade'
        elif parsed_latest_version < parsed_current_version:
            return 'delorean'
        elif parsed_latest_version == parsed_current_version:
            return 'current'
    except Exception as exc:

        warn(f'Unable to determine whether the version is older or newer ({exc})')