Init project
This commit is contained in:
32
birthday_pool_bot/telegram_bot/cli.py
Normal file
32
birthday_pool_bot/telegram_bot/cli.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import asyncio
|
||||
|
||||
import typer
|
||||
|
||||
from birthday_pool_bot.repositories import RepositoriesContainer
|
||||
from .fabric import get_telegram_bot_service
|
||||
from .settings import TelegramBotSettings
|
||||
|
||||
|
||||
def callback(ctx: typer.Context):
|
||||
ctx.obj["settings"] = ctx.obj["settings"].telegram_bot
|
||||
|
||||
|
||||
def run(ctx: typer.Context):
|
||||
settings: TelegramBotSettings = ctx.obj["settings"]
|
||||
repositories_container: RepositoriesContainer = ctx.obj["repositories_container"]
|
||||
|
||||
service = get_telegram_bot_service(
|
||||
settings=settings,
|
||||
repositories_container=repositories_container,
|
||||
)
|
||||
|
||||
asyncio.run(service.run())
|
||||
|
||||
|
||||
def get_cli() -> typer.Typer:
|
||||
cli = typer.Typer()
|
||||
|
||||
cli.callback()(callback)
|
||||
cli.command(name="run")(run)
|
||||
|
||||
return cli
|
||||
Reference in New Issue
Block a user