diff --git a/src/caosadvancedtools/models/parser.py b/src/caosadvancedtools/models/parser.py index ad149222b5b90671a50943dc00bc9de8074a42f1..25fe83d9b2a0afc2533fdcd46f72a990348cf4e0 100644 --- a/src/caosadvancedtools/models/parser.py +++ b/src/caosadvancedtools/models/parser.py @@ -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)