add help text to python script
authorMoritz Warning <moritzwarning@web.de>
Sun, 2 Feb 2020 14:34:23 +0000 (15:34 +0100)
committerMoritz Warning <moritzwarning@web.de>
Sun, 2 Feb 2020 14:34:23 +0000 (15:34 +0100)
collect.py

index 09e0c64c2b3833a32baedff606e29c526d867ce4..34721103d2a3f89ec0a26e9ae7036c08270efa48 100755 (executable)
@@ -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: {} <openwrt-bin-dir>\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 = []