Maybe you want to try this command line tool to download ERA5 data from the CDS. Documentation is available at https://era5cli.readthedocs.io/en/latest/.