data-anaxi/anaxi/cli.py

59 lines
1.5 KiB
Python
Raw Normal View History

2024-08-08 18:10:32 +02:00
import importlib.metadata
import click
import pyfiglet
from anaxi.logging import get_anaxi_logger
2024-08-09 14:45:10 +02:00
from anaxi.processes import (
run_cosmos_db_healthcheck_process,
run_postgres_healthcheck_process,
2024-08-13 15:02:03 +02:00
run_sync_process,
2024-08-09 14:45:10 +02:00
)
2024-08-08 18:34:27 +02:00
logger = get_anaxi_logger(__name__)
2024-08-08 18:10:32 +02:00
@click.group()
def cli():
logger.info(pyfiglet.figlet_format("\nWelcome to anaxi", font="big"))
logger.info(f"Running anaxi version: {importlib.metadata.version('anaxi')}")
@cli.command()
def smoke_test():
print("Oink oink!")
print(
"""
__,---.__
,-' `-.__
&/ `._\ _\\
/ ''._
| , (")
|__,'`-..--|__|--''
"""
)
2024-08-08 18:34:27 +02:00
@cli.command()
@click.option("--cosmos-db-id", type=click.STRING, required=True)
2024-08-08 18:34:27 +02:00
def cosmos_db_healthcheck(cosmos_db_id):
logger.info("Starting a Cosmos DB healthcheck.")
run_cosmos_db_healthcheck_process(cosmos_db_id)
logger.info("Finished the Cosmos DB healthcheck.")
2024-08-09 14:45:10 +02:00
@cli.command()
@click.option("--postgres-database", type=click.STRING, required=True)
def postgres_healthcheck(postgres_database):
logger.info("Starting a Postgres healthcheck.")
run_postgres_healthcheck_process(postgres_database)
logger.info("Finished the Postgres healthcheck.")
2024-08-13 15:02:03 +02:00
@cli.command()
@click.option("--stream-id", type=click.STRING, required=True)
def sync_stream(stream_id):
logger.info("Starting a sync.")
run_sync_process(stream_id)
logger.info("Finished sync.")