import argparse
import asyncio

from lunatone_rest_api_client.discovery import async_discover_devices_stream


parser = argparse.ArgumentParser(prog="Discovery")
parser.add_argument(
    "-i", "--ip", type=str, help="Specify the IP address of a network interface"
)
arguments = parser.parse_args()


async def main():
    loop = asyncio.get_running_loop()
    async for dev in async_discover_devices_stream(
        loop,
        timeout=4.0,
        local_ip=arguments.ip,
    ):
        print(dev)


if __name__ == "__main__":
    asyncio.run(main())
