mirror of
https://github.com/controllerzz/carbus_lib.git
synced 2026-07-19 12:10:13 +03:00
v0.1.8 fix cli
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
@@ -232,6 +233,18 @@ async def main(host: str = "0.0.0.0", port: int = 9000) -> None:
|
||||
await srv.serve_forever()
|
||||
|
||||
|
||||
def cli() -> None:
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--host", default="0.0.0.0")
|
||||
ap.add_argument("--port", type=int, default=9000)
|
||||
args = ap.parse_args()
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
|
||||
)
|
||||
asyncio.run(main(host=args.host, port=args.port))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(name)s: %(message)s")
|
||||
asyncio.run(main())
|
||||
cli()
|
||||
|
||||
Reference in New Issue
Block a user