#!/usr/bin/python

"""
A nuclear data downloading package that facilitates the reproduction of cross
section collections. Use the command line tool or Python API to download the h5
cross sections for just the isotopes / elements that you want. Specify the
prefered nuclear data libraries to use. Automaticallly avoid duplication and
generation of custom cross_section.xml files
"""

import argparse
from pathlib import Path
from typing import List

from openmc_data_downloader import just_in_time_library_generator, LIB_OPTIONS


if __name__ == '__main__':

    parser = argparse.ArgumentParser()

    parser.add_argument('-l', '--libraries', choices=LIB_OPTIONS, nargs='*',
                        help="The nuclear data libraries to search through \
                        when searching for cross sections. Multiple libaries \
                        are acceptable and will be preferentially utilised in \
                        the order provided", default=[], required=True)
    parser.add_argument('-i', '--isotopes', nargs='*', default=[], help="The \
                        isotopes to download")
    parser.add_argument('-e', '--elements', nargs='*', default=[], help="The \
                        elements to download")
    parser.add_argument(
        '-m', '--materials_xml', nargs='*', default=[], help="The \
                        filename of the materials.xml file to provide cross \
                        sections for")
    parser.add_argument('-d', '--destination', type=Path, default=None,
                        help='Directory to create new library in')

    args = parser.parse_args()

    just_in_time_library_generator(
        libraries=args.libraries,
        isotopes=args.isotopes,
        elements=args.elements,
        destination=args.destination,
        materials_xml=args.materials_xml,
        set_OPENMC_CROSS_SECTIONS=False
    )
