From b5a59d1f4700a94163003e076864fdf981416ad7 Mon Sep 17 00:00:00 2001 From: Moritz Warning Date: Sun, 2 Feb 2020 15:34:23 +0100 Subject: [PATCH] add help text to python script --- collect.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/collect.py b/collect.py index 09e0c64..3472110 100755 --- a/collect.py +++ b/collect.py @@ -11,16 +11,12 @@ SUPPORTED_METADATA_VERSION = 1 paths = [] output = {} -for arg in sys.argv[1:]: - if os.path.isdir(arg): - for path in Path(arg).rglob('*.json'): - paths.append(path) - elif os.path.isfile(arg) and arg.endswith('.json'): - paths.append(arg) - else: - sys.stderr.write("Not a directory and not a .json file: {} => abort\n".format(arg)) - exit(1) +if len(sys.argv) != 2: + sys.stderr.write("Merge json files generated by OpenWrt.\n\nUsage: {} \n\nThe result will be printed to stdout.\n".format(sys.argv[0])) + exit(1) +for path in Path(sys.argv[1]).rglob('*.json'): + paths.append(path) def collect_names(prefix, images): names = [] -- 2.30.2