[run_flaschengeist] Improved export command

Export now supports --no-core flag, if set no core models will
get exported.
Also --plugins was changed to support a list of plugins,
if no list is given the old behavior is taken (export all plugins).
If a list of plugins is given, only those plugins are exported.
This commit is contained in:
Ferdinand Thiessen 2021-05-26 16:47:03 +02:00
parent 776332d5fe
commit 8696699ecb
2 changed files with 23 additions and 15 deletions

View File

@ -567,6 +567,7 @@ def get_columns(userid, current_session):
userController.persist()
return no_content()
@PriceListPlugin.blueprint.route("/users/<userid>/pricecalc_columns_order", methods=["GET", "PUT"])
@login_required()
def get_columns_order(userid, current_session):

View File

@ -156,9 +156,11 @@ def export(arguments):
app = create_app()
with app.app_context():
gen = InterfaceGenerator(arguments.namespace, arguments.file)
if not arguments.no_core:
gen.run(models)
if arguments.plugins:
if arguments.plugins is not None:
for entry_point in pkg_resources.iter_entry_points("flaschengeist.plugin"):
if len(arguments.plugins) == 0 or entry_point.name in arguments.plugins:
plg = entry_point.load()
if hasattr(plg, "models") and plg.models is not None:
gen.run(plg.models)
@ -183,7 +185,12 @@ if __name__ == "__main__":
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")
parser_export.add_argument("--plugins", help="Also export plugins", action="store_true")
parser_export.add_argument(
"--no-core",
help="Do not export core declarations (only useful in conjunction with --plugins)",
action="store_true",
)
parser_export.add_argument("--plugins", help="Also export plugins (none means all)", nargs="*")
args = parser.parse_args()
args.func(args)