Browse Source

Fix usability around CLI

The cli is super straightforward, with just a single argument. But, that
doesn't mean people won't forget the config file or specify extra args
by mistake. This commit adds a --help/-h flag which will print the usage
information. It also will handle the case when an incorrect number of
arguments are supplied and refer the user to --help.
changes/20/506120/1
Matthew Treinish 4 years ago
parent
commit
4a5adf8cca
No known key found for this signature in database GPG Key ID: FD12A0F214C9E177
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      mqtt_statsd/daemon.py

+ 6
- 0
mqtt_statsd/daemon.py View File

@ -69,6 +69,12 @@ class MQTTStat(threading.Thread):
def main():
conf = None
if len(sys.argv) != 2:
print("Incorrect number of arguments, see --help")
sys.exit(1)
if sys.argv[1] == '--help' or sys.argv[1] == '-h':
print("usage: mqtt_statsd <config file>")
sys.exit(0)
with open(sys.argv[1], 'r') as conf_file:
conf = yaml.load(conf_file.read())
if not conf:


Loading…
Cancel
Save