Skip to content

Commit 56f5ebf

Browse files
authored
Merge pull request #109 from Its-Just-Nans/add-main
feat: Export the main and create `__main__.py`
2 parents adc15a5 + bcfa6ba commit 56f5ebf

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

mqtt_exporter/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
"""MQTT Prometheus exporter."""
2+
3+
from .main import main_mqtt_exporter

mqtt_exporter/__main__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/env python3
2+
3+
"""
4+
MQTT Prometheus exporter
5+
6+
You can run it with
7+
8+
```sh
9+
python -m pip install mqtt-exporter
10+
python -m mqtt_exporter
11+
```
12+
13+
"""
14+
15+
from .main import main_mqtt_exporter
16+
17+
if __name__ == "__main__":
18+
main_mqtt_exporter()

mqtt_exporter/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,8 @@ def stop_request(signum, frame):
551551
client.loop_forever()
552552

553553

554-
def main():
554+
def main_mqtt_exporter():
555+
"""Main function of mqtt exporter"""
555556
parser = argparse.ArgumentParser(
556557
prog="MQTT-exporter",
557558
description="Simple generic MQTT Prometheus exporter for IoT working out of the box.",
@@ -583,4 +584,4 @@ def main():
583584

584585

585586
if __name__ == "__main__":
586-
main()
587+
main_mqtt_exporter()

0 commit comments

Comments
 (0)