import click from pathlib import Path from json_parser import parse_json from psm_parser import write_psm from xml_parser import get_xml_data, add_connection, write_xml_data @click.command @click.option('-j', '--json', type=Path, required=True, help='Path to the JSON file') @click.option('-x', '--xml', type=Path, required=True, help='Path to the XML file. If the file does not exist, a default configuration will be generated.') @click.option('-n', '--name', type=str, required=True, help='Name of the connection') @click.option('-d', '--description', type=str, required=True, help='Description of the connection') @click.option('-p', '--pretty', is_flag=True, default=False, help='Enable pretty output') def main(json: Path, xml: Path, name: str, description: str, pretty: bool): xml_data = get_xml_data(xml) field_names = parse_json(json) root = add_connection(xml_data, name, field_names, description=description) write_xml_data(root, xml, pretty=pretty) write_psm(name, field_names) if __name__ == "__main__": main()