From bc623fc93fe4e31bc3ec902d0520dc99529adbf4 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 21 May 2020 09:58:22 +1000 Subject: [PATCH] Print usage if no action is specified --- src/pyelephant.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pyelephant.py b/src/pyelephant.py index e0ab8f7..7670038 100755 --- a/src/pyelephant.py +++ b/src/pyelephant.py @@ -29,9 +29,13 @@ def ls(session: sa.orm.Session): ############################################################################### if __name__ == '__main__': import sys + import argparse + + def none(parser: argparse.ArgumentParser): + parser.print_usage() + sys.exit(1) def main(): - import argparse import os actions = { @@ -41,6 +45,7 @@ if __name__ == '__main__': } parser = argparse.ArgumentParser() + parser.set_defaults(func=lambda x: none(parser)) subparsers = parser.add_subparsers() add_parser = subparsers.add_parser('add')