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.
This commit is contained in:
parent
80852893a5
commit
4a5adf8cca
@ -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…
x
Reference in New Issue
Block a user