import click

from globus_cli.parsing import common_options, endpoint_id_arg, server_id_arg
from globus_cli.safeio import formatted_print, FORMAT_TEXT_RECORD

from globus_cli.services.transfer import get_client


@click.command('show', help='Show a server belonging to an endpoint')
@common_options
@endpoint_id_arg
@server_id_arg
def server_show(endpoint_id, server_id):
    """
    Executor for `globus endpoint server show`
    """
    client = get_client()

    server_doc = client.get_endpoint_server(endpoint_id, server_id)
    if not server_doc['uri']:  # GCP endpoint server
        fields = (('ID', 'id'), ('Is Connected', 'is_connected'),
                  ('Is Paused (macOS only)', 'is_paused'))
    else:
        def advertised_port_summary(server):
            def get_range_summary(start, end):
                return ('unspecified' if not start and not end
                        else 'unrestricted' if start == 1024 and end == 65535
                        else '{}-{}'.format(start, end))

            return "incoming {}, outgoing {}".format(
                       get_range_summary(server['incoming_data_port_start'],
                                         server['incoming_data_port_end']),
                       get_range_summary(server['outgoing_data_port_start'],
                                         server['outgoing_data_port_end']),
                   )

        fields = (('ID', 'id'), ('URI', 'uri'), ('Subject', 'subject'),
                  ('Data Ports', advertised_port_summary))

    formatted_print(server_doc, text_format=FORMAT_TEXT_RECORD,
                    fields=fields)

@@ -5,16 +5,44 @@
 rt click
+%0Afrom textwrap import dedent
 %0A%0Afrom g
@@ -639,99 +639,225 @@
 d'),
- ('Is Connected', 'is_connected'),%0A                  ('Is Paused (macOS only)', 'is_paused'
+)%0A        text_epilog = dedent(%22%22%22%0A            This server is for a Globus Connect Personal installation.%0A%0A            For its connection status, try:%0A            globus endpoint show %7B%7D%0A        %22%22%22.format(endpoint_id
 ))%0A 
@@ -1668,16 +1668,43 @@
 ummary))
+%0A        text_epilog = None
 %0A%0A    fo
@@ -1761,16 +1761,16 @@
 RECORD,%0A
-
         
@@ -1794,10 +1794,35 @@
 s=fields
+, text_epilog=text_epilog
 )%0A

Drop is_connected/paused on endpoint server show