Skip to content
Snippets Groups Projects
Commit 534db1c8 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

ENH: allow using the parser as cmd line tool

parent 6de42175
No related branches found
No related tags found
2 merge requests!54REL: Release 0.5.0,!50ENH: allow using the parser as cmd line tool
Pipeline #26553 passed
......@@ -36,6 +36,7 @@ Parents can be provided under the 'inherit_from_xxxx' keywords. The value needs
to be a list with the names. Here, NO NEW entities can be defined.
"""
import json
import argparse
import re
import sys
import yaml
......@@ -796,5 +797,25 @@ class JsonSchemaParser(Parser):
if __name__ == "__main__":
model = parse_model_from_yaml('data_model.yml')
print(model)
parser = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("data_model",
help="Path name of the data model file (yaml or json) to be used.")
parser.add_argument("--sync", action="store_true",
help="Whether or not to sync the data model with the server.")
parser.add_argument("--noquestion", action="store_true",
help="Whether or not to ask questions during synchronization.")
parser.add_argument("--print", action="store_true",
help="Whether or not to print the data model.")
args = parser.parse_args()
if args.data_model.endswith(".json"):
model = parse_model_from_json_schema(args.data_model)
elif args.data_model.endswith(".yml") or args.data_model.endswith(".yaml"):
model = parse_model_from_yaml(args.data_model)
else:
RuntimeError("did not recognize file ending")
if args.print:
print(model)
if args.sync:
model.sync_data_model(noquestion=args.noquestion)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment