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 c918b82
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
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 c918b82

Please sign in to comment.