improve generate script

This commit is contained in:
Wolfgang Hottgenroth 2021-07-28 17:23:35 +02:00
parent e9aeeb12cc
commit f33d4f4d25
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F

View File

@ -5,9 +5,14 @@ import argparse
parser = argparse.ArgumentParser(description="generate.py")
parser.add_argument('--schema', '-s',
help='Schema file',
help='Schema file. Default: schema.json in the current folder.',
required=False,
default='./schema.json')
parser.add_argument('--template', '-t',
help="""Template file, templates files must be named as the final output file
with an additional .tmpl extension. Default: all template files in the current folder.""",
required=False,
default="*.tmpl")
args = parser.parse_args()
@ -35,7 +40,7 @@ for table in schema["tables"]:
column["apitype"] = 'number'
column["jstype"] = 'number'
for f in glob.glob("*.tmpl"):
for f in glob.glob(args.template):
print(f"process {f}")
tmpl = Template(file=f, searchList=[schema])
with open(f[:-5], 'w') as outFile: