def _parse_args()

in util/sync_buckets.py [0:0]


def _parse_args():
    def _aws_credentials_type(value):
        return tuple(value.strip().split(","))

    parser = argparse.ArgumentParser(description="Sync the content of a source bucket to a set of destination buckets")
    parser.add_argument(
        "--partition", choices=PARTITIONS, help="AWS Partition where to update the files", required=True
    )
    parser.add_argument(
        "--regions",
        type=str,
        help="Regions where the files would be deployed to",
        required=False,
        nargs="+",
        default=[],
    )
    parser.add_argument(
        "--autodetect-regions",
        action="store_true",
        help="If set ec2.describe_regions is used to retrieve regions. "
        "Additional regions (e.g. opt-in) can be specified with --regions",
        required=False,
        default=False,
    )
    parser.add_argument(
        "--dest-bucket",
        type=str,
        help="Bucket to upload to, defaults to {region}-aws-parallelcluster",
        required=False,
        default="{region}-aws-parallelcluster",
    )
    parser.add_argument("--src-bucket", type=str, help="Source bucket", required=True)
    parser.add_argument("--src-bucket-region", type=str, help="Source bucket region", required=True)
    parser.add_argument("--src-files", help="Files to sync", nargs="+", required=True)
    parser.add_argument(
        "--integrity-check",
        help="If this option is specified, a file having the same name of the src files and as extension the hashing "
        "algorithm is expected to be found in the source bucket. This file is used to perform checksum validation "
        "and is also uploaded to the destination bucket",
        choices=list(HashingAlgorithm),
        type=HashingAlgorithm,
        required=False,
    )
    parser.add_argument(
        "--credentials",
        help="STS credential endpoint, in the format <region>,<endpoint>,<ARN>,<externalId>."
        "Could be specified multiple times",
        required=False,
        nargs="+",
        type=_aws_credentials_type,
        default=[],
    )
    parser.add_argument(
        "--deploy",
        action="store_true",
        help="If deploy is false, we will perform a dryrun and no file will be pushed to buckets",
        default=False,
        required=False,
    )
    parser.add_argument(
        "--update-existing",
        action="store_true",
        help="Overrides existing files in dest buckets",
        default=False,
        required=False,
    )

    args = parser.parse_args()

    if args.autodetect_regions:
        args.regions.extend(get_aws_regions(args.partition))

    _validate_args(args, parser)
    return args