diff --git a/notification_producer/cli.py b/notification_producer/cli.py new file mode 100644 index 0000000..c4bc887 --- /dev/null +++ b/notification_producer/cli.py @@ -0,0 +1,29 @@ +import asyncio +import typer +from rich.console import Console +from notification_producer.producer_client import ProducerClient + +console = Console() +cli_app = typer.Typer(rich_markup_mode="rich") +notify = typer.Typer() + + +@cli_app.command() +def up( + 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[/].", + ), +): + """ + This command [b]start[/] the [yellow b]producer[/] to send messages in [b]the interactive mode[/]. + """ + + client = ProducerClient(ip, port) + asyncio.run(client.notify_interactive()) + + diff --git a/notification_producer/main.py b/notification_producer/main.py index a17135e..b1c401c 100644 --- a/notification_producer/main.py +++ b/notification_producer/main.py @@ -19,12 +19,12 @@ ########################################################################## import asyncio -from .producer_client import ProducerClient +from notification_producer.producer_client import ProducerClient +from notification_producer.cli import cli_app def main(): - client = ProducerClient('127.0.0.1', 5554) - asyncio.run(client.notify_interactive()) + cli_app() if __name__ == '__main__':