[Skript] run_flaschegeist now allows setting the typescript namespace

This commit is contained in:
Ferdinand Thiessen 2020-10-24 20:11:50 +02:00
parent d2858c8c76
commit f238491206
1 changed files with 2 additions and 2 deletions

View File

@ -28,7 +28,6 @@ def export(arguments):
import flaschengeist.system.models as models
known = []
done = []
classes = {}
def pytype(cls):
@ -69,7 +68,7 @@ def export(arguments):
with app.app_context():
walker(("models", models))
with open(arguments.file, "w") as file:
file.write("declare namespace FG {\n")
file.write("declare namespace {} \{\n".format(arguments.namespace))
for cls, params in classes.items():
if isinstance(params, str):
file.write("\ttype {} = {};\n".format(cls, params))
@ -98,6 +97,7 @@ if __name__ == "__main__":
parser_export = subparsers.add_parser("export", help="export models to typescript interfaces")
parser_export.set_defaults(func=export)
parser_export.add_argument("--file", help="Filename where to save", default="flaschengeist.d.ts")
parser_export.add_argument("--namespace", help="Namespace of declarations", default="FG")
args = parser.parse_args()
args.func(args)