2021-01-06 16:17:05 +01:00
|
|
|
"""The entry point for all CLI scripts in the project."""
|
2020-08-04 21:14:40 +02:00
|
|
|
|
|
|
|
|
from typing import Any
|
|
|
|
|
|
|
|
|
|
import click
|
2021-01-06 16:17:05 +01:00
|
|
|
from click import core as cli_core
|
2020-08-04 21:14:40 +02:00
|
|
|
|
|
|
|
|
import urban_meal_delivery
|
|
|
|
|
|
|
|
|
|
|
2021-01-06 16:17:05 +01:00
|
|
|
def show_version(ctx: cli_core.Context, _param: Any, value: bool) -> None:
|
2020-08-04 21:14:40 +02:00
|
|
|
"""Show the package's version."""
|
|
|
|
|
# If --version / -V is NOT passed in,
|
|
|
|
|
# continue with the command.
|
|
|
|
|
if not value or ctx.resilient_parsing:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# Mimic the colors of `poetry version`.
|
|
|
|
|
pkg_name = click.style(urban_meal_delivery.__pkg_name__, fg='green') # noqa:WPS609
|
|
|
|
|
version = click.style(urban_meal_delivery.__version__, fg='blue') # noqa:WPS609
|
|
|
|
|
# Include a warning for development versions.
|
|
|
|
|
warning = click.style(' (development)', fg='red') if '.dev' in version else ''
|
|
|
|
|
click.echo(f'{pkg_name}, version {version}{warning}')
|
|
|
|
|
ctx.exit()
|
|
|
|
|
|
|
|
|
|
|
2021-01-06 16:17:05 +01:00
|
|
|
@click.group()
|
2020-08-04 21:14:40 +02:00
|
|
|
@click.option(
|
|
|
|
|
'--version',
|
|
|
|
|
'-V',
|
|
|
|
|
is_flag=True,
|
|
|
|
|
callback=show_version,
|
|
|
|
|
is_eager=True,
|
|
|
|
|
expose_value=False,
|
|
|
|
|
)
|
2021-01-06 16:17:05 +01:00
|
|
|
def entry_point() -> None:
|
2020-08-04 21:14:40 +02:00
|
|
|
"""The urban-meal-delivery research project."""
|