Skip to content

Commit 9e8ae73

Browse files
author
Max KvR
committed
feat: standardized CLI #19
1 parent 27de1e3 commit 9e8ae73

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

metricq_sink_websocket/main.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import click_log # type: ignore
99
from aiohttp import web
1010
from metricq import get_logger
11+
from metricq.cli import metricq_command
1112

1213
from .routes import setup_routes
1314
from .sink import Sink
@@ -78,14 +79,12 @@ def create_app(token: str, url: str, port: int) -> web.Application:
7879
return app
7980

8081

81-
@click.command()
82-
@click.argument("url", default="amqp://localhost/")
83-
@click.option("--token", default="metricq-sink-websocket")
82+
@metricq_command(default_token="metricq-sink-websocket")
8483
@click.option("--host", default="0.0.0.0")
8584
@click.option("--port", type=int, default=3000)
8685
@click.version_option(client_version)
8786
@click_log.simple_verbosity_option(logger) # type: ignore
88-
def runserver_cmd(url: str, token: str, host: str, port: int) -> None:
87+
def runserver_cmd(server: str, token: str, host: str, port: int) -> None:
8988
try:
9089
import uvloop # type: ignore
9190

@@ -94,5 +93,5 @@ def runserver_cmd(url: str, token: str, host: str, port: int) -> None:
9493
except ImportError:
9594
logger.debug("using default event loop")
9695

97-
app = create_app(token, url, port)
96+
app = create_app(token, server, port)
9897
web.run_app(app, host=host, port=port)

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ install_requires =
2222
click ~= 8.1.7
2323
click-completion ~= 0.5.2
2424
click_log ~= 0.4.0
25-
metricq ~= 5.3.0
25+
metricq[cli] ~= 5.4.0
2626

2727
[options.extras_require]
2828
uvloop =

0 commit comments

Comments
 (0)