Skip to content

Commit

Permalink
feat: standardized cli
Browse files Browse the repository at this point in the history
  • Loading branch information
devmaxde committed Jan 9, 2025
1 parent 2a5cb05 commit 72487d0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/metricq/metricq-python:v5.3 AS builder
FROM ghcr.io/metricq/metricq-python:v5.4 AS builder
LABEL maintainer="[email protected]"

USER root
Expand All @@ -14,7 +14,7 @@ COPY --chown=metricq:metricq . /home/metricq/source-snmp
WORKDIR /home/metricq/source-snmp
RUN pip install --user .

FROM ghcr.io/metricq/metricq-python:v5.3
FROM ghcr.io/metricq/metricq-python:v5.4

USER metricq
COPY --from=BUILDER --chown=metricq:metricq /home/metricq/.local /home/metricq/.local
Expand Down
10 changes: 3 additions & 7 deletions metricq_source_snmp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import traceback
from collections import defaultdict
from collections.abc import Awaitable

from queue import Empty
from typing import Any, Mapping, Optional, Sequence, TypeVar, Iterable
from typing import Any, Iterable, Mapping, Optional, Sequence, TypeVar

import click
import click_log # type: ignore
import metricq
from metricq.cli import metricq_command
from metricq.logging import get_logger
from pysnmp.hlapi.asyncio import CommunityData # type: ignore
from pysnmp.hlapi.asyncio import (
Expand All @@ -30,7 +30,6 @@

from .version import __version__ # noqa: F401 # magic import for automatic version


T = TypeVar("T")


Expand Down Expand Up @@ -362,10 +361,7 @@ def on_signal(self, signal: str) -> None:
super().on_signal(signal)


@click.command()
@click.option("--server", default="amqp://localhost/")
@click.option("--token", default="source-py-snmp")
@click_log.simple_verbosity_option(logger) # type: ignore
@metricq_command(default_token="snmp-source")
def run(server: str, token: str) -> None:
src = SnmpSource(token=token, management_url=server)
src.run()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"aiomonitor",
"click",
"click_log",
"metricq ~= 5.3",
"metricq[cli] ~= 5.4",
"pysnmp-lextudio",
"uvloop",
],
Expand Down

0 comments on commit 72487d0

Please sign in to comment.