import argparse
import os
from utils import download_file_from_nexus, get_config_global, add_nexus_arguments, get_nexus_base_url
from github.env import get_required_env_var


if __name__ == "__main__":
    # Parse command-line arguments
    parser = argparse.ArgumentParser(description="Get input parameters")
    add_nexus_arguments(parser)
    parser.add_argument('--config_file', type=str, help='Firefly config file path', required=True)

    args = parser.parse_args()

    username = get_required_env_var("NEXUS_USERNAME")
    password = get_required_env_var("NEXUS_PASSWORD")

    print(f"current working directory: {os.getcwd()}")

    config_global = get_config_global(args.config_file)

    url = f"{get_nexus_base_url(args)}/localav/engines/engines.zip"

    workDirectoryPath = config_global["workDirectoryPath"]
    if workDirectoryPath == "":
        workDirectoryPath = os.getcwd()
        dest_path = workDirectoryPath + os.sep + "testing" + os.sep + "blades" + os.sep + "threat-prevention" + os.sep + "engines"
    else:
        dest_path = workDirectoryPath + os.sep + "engines"

    download_file_from_nexus(username, password, url, dest_path, True, "")

