help if no subcommand specified

This commit is contained in:
boyska 2019-11-02 16:04:51 +01:00
parent 4aaf0acd62
commit 7db3a2ba3a

View file

@ -11,6 +11,7 @@ def main_list(args):
m = EventModel(args.file)
for alarm, action in m.get_all_alarms_expanded():
json.dump(dict(alarm=alarm, action=action), sys.stdout, indent=4)
sys.stdout.write('\n')
def main_getaction(args):
@ -29,6 +30,7 @@ def main_add(args):
def main():
conf = get_conf()
p = argparse.ArgumentParser()
p.set_defaults(func=None)
p.add_argument(
"-f", "--file", help="Filepath for DB", required=False, default=conf["DB_URI"]
)
@ -45,6 +47,9 @@ def main():
sub_add.set_defaults(func=main_add)
args = p.parse_args()
if args.func is None:
p.print_help()
sys.exit(2)
args.func(args)