import argparse
from pathlib import Path

from worker_configuration.validator import validate_file


def main():
    parser = argparse.ArgumentParser(
        prog="worker-configuration",
        description="Scripts for Arkindex worker configuration management and validation",
    )

    commands = parser.add_subparsers()
    validate = commands.add_parser(
        "validate", help="Validate an Arkindex worker configuration file in YAML format"
    )
    validate.set_defaults(func=validate_file)
    validate.add_argument("path", type=Path)

    args = vars(parser.parse_args())
    if "func" in args:
        args.pop("func")(**args)
    else:
        parser.print_help()


if __name__ == "__main__":
    main()
