def version(cluster_name: str, group: Optional[int], member_names: List[str]) -> None:
    """Process ``version`` command of ``patronictl`` utility.

    Show version of:
        * ``patronictl`` on invoker;
        * ``patroni`` on all members of the cluster;
        * ``PostgreSQL`` on all members of the cluster.

    :param cluster_name: name of the Patroni cluster.
    :param group: filter which Citus group we should get members from. Refer to the module note for more details.
    :param member_names: filter which members we should get version information from.
    """
    click.echo("patronictl version {0}".format(__version__))

    if not cluster_name:
        return

    click.echo("")
    cluster = get_dcs(cluster_name, group).get_cluster()
    for m in get_all_members(cluster, group, CtlPostgresqlRole.ANY):
        if m.api_url:
            if not member_names or m.name in member_names:
                try:
                    response = request_patroni(m)
                    data = json.loads(response.data.decode('utf-8'))
                    version = data.get('patroni', {}).get('version')
                    pg_version = data.get('server_version')
                    pg_version_str = " PostgreSQL {0}".format(format_pg_version(pg_version)) if pg_version else ""
                    click.echo("{0}: Patroni {1}{2}".format(m.name, version, pg_version_str))
                except Exception as e:
                    click.echo("{0}: failed to get version: {1}".format(m.name, e))
Process ``version`` command of ``patronictl`` utility.

    Show version of:
        * ``patronictl`` on invoker;
        * ``patroni`` on all members of the cluster;
        * ``PostgreSQL`` on all members of the cluster.

    :param cluster_name: name of the Patroni cluster.
    :param group: filter which Citus group we should get members from. Refer to the module note for more details.
    :param member_names: filter which members we should get version information from.
    
patroni/ctl.py