From b6bc41da4c0e3780be18329a8eeb98ae1b4023ca Mon Sep 17 00:00:00 2001 From: KKlochko Date: Tue, 12 Dec 2023 20:59:40 +0200 Subject: [PATCH] Add the CLI command to send one notification. --- notification_producer/cli.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/notification_producer/cli.py b/notification_producer/cli.py index c4bc887..b6fb31e 100644 --- a/notification_producer/cli.py +++ b/notification_producer/cli.py @@ -6,6 +6,7 @@ from notification_producer.producer_client import ProducerClient console = Console() cli_app = typer.Typer(rich_markup_mode="rich") notify = typer.Typer() +cli_app.add_typer(notify, name="notify", help="To send notification.") @cli_app.command() @@ -27,3 +28,30 @@ def up( asyncio.run(client.notify_interactive()) +@notify.command() +def message( + ip: str = typer.Option( + "127.0.0.1", "--ip", "-i", + help="The server's ip.", + ), + port: int = typer.Option( + 5554, "--port", "-p", + help="The server's port for [b]producers[/].", + ), + notification_title: str = typer.Option( + "notification", "--title", "-t", + help="[b yellow]The title[/] for the [y b]notification[/]." + ), + # TODO as argument (required) + notification_message: str = typer.Option( + 'hello', "--title", "-t", + help="[b yellow]The message[/] for the [y b]notification[/]." + ), +): + """ + This command [b]send[/] [yellow b]one notification[/]. + """ + + client = ProducerClient(ip, port) + asyncio.run(client.notify(notification_title, notification_message)) +