[Skript] run_flaschegeist now allows setting the typescript namespace
This commit is contained in:
parent
d2858c8c76
commit
f238491206
|
@ -28,7 +28,6 @@ def export(arguments):
|
||||||
import flaschengeist.system.models as models
|
import flaschengeist.system.models as models
|
||||||
|
|
||||||
known = []
|
known = []
|
||||||
done = []
|
|
||||||
classes = {}
|
classes = {}
|
||||||
|
|
||||||
def pytype(cls):
|
def pytype(cls):
|
||||||
|
@ -69,7 +68,7 @@ def export(arguments):
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
walker(("models", models))
|
walker(("models", models))
|
||||||
with open(arguments.file, "w") as file:
|
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():
|
for cls, params in classes.items():
|
||||||
if isinstance(params, str):
|
if isinstance(params, str):
|
||||||
file.write("\ttype {} = {};\n".format(cls, params))
|
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 = subparsers.add_parser("export", help="export models to typescript interfaces")
|
||||||
parser_export.set_defaults(func=export)
|
parser_export.set_defaults(func=export)
|
||||||
parser_export.add_argument("--file", help="Filename where to save", default="flaschengeist.d.ts")
|
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 = parser.parse_args()
|
||||||
args.func(args)
|
args.func(args)
|
||||||
|
|
Loading…
Reference in New Issue