def distros(ctx, opts, package_format):
    """List available distributions."""
    # Use stderr for messages if the output is something else (e.g.  # JSON)
    use_stderr = opts.output != "pretty"

    click.echo("Getting list of distributions ... ", nl=False, err=use_stderr)

    context_msg = "Failed to get list of distributions!"
    with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg):
        with maybe_spinner(opts):
            distros_ = list_distros(package_format=package_format)

    click.secho("OK", fg="green", err=use_stderr)

    if utils.maybe_print_as_json(opts, distros_):
        return

    headers = ["Distro", "Release", "Format", "Distro / Release (Identifier)"]
    if package_format:
        headers.remove("Format")

    rows = []
    for distro in sorted(distros_, key=itemgetter("slug")):
        if not distro["versions"]:
            continue

        for release in sorted(distro["versions"], key=itemgetter("slug")):
            row = [
                click.style(distro["name"], fg="cyan"),
                click.style(release["name"], fg="yellow"),
                click.style(distro["format"], fg="blue"),
                "%(distro)s/%(release)s"
                % {
                    "distro": click.style(distro["slug"], fg="magenta"),
                    "release": click.style(release["slug"], fg="green"),
                },
            ]

            if package_format:
                row.pop(2)  # Remove format column

            rows.append(row)

    if distros_:
        click.echo()
        utils.pretty_print_table(headers, rows)

    click.echo()

    num_results = sum(
        1 for distro in distros_ for release in distro["versions"] if release
    )
    list_suffix = "distribution release%s" % ("s" if num_results != 1 else "")
    utils.pretty_print_list_info(num_results=num_results, suffix=list_suffix)