
    k                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ dd	l
mZ  G d
 dej                        Zy)zThe Browse command.    )absolute_import)division)unicode_literals)base)browser_dispatcher)flags)log)
propertiesc                   .    e Zd ZdZddiZed        Zd Zy)Browsez/Open the specified service(s) in a browser.

  EXAMPLESa            To show the url for the default service in the browser, run:

              $ {command} default

          To show version `v1` of service `myService` in the browser, run:

              $ {command} myService --version="v1"

          To show multiple services side-by-side, run:

              $ {command} default otherService

          To show multiple services side-by-side with a specific version, run:

              $ {command} s1 s2 --version=v1
          c                     | j                   j                  d       t        j                  j	                  |        | j                  ddd       | j                  ddd	       y )
Nz_
          table(
            service:label=SERVICE,
            url:label=URL
          )
    services+zI        The services to open (optionally filtered by the --version flag).)nargshelpz	--versionz-vz            If specified, open services with a given version. If not
            specified, use a version based on the service's traffic split .
            )r   )display_info	AddFormatr   LAUNCH_BROWSERAddToParseradd_argument)parsers    "lib/surface/app/services/browse.pyArgszBrowse.Args7   sq    
!! # 	 
$$V,
M  N
       c           	      x   t         j                  j                  j                  j	                  d      }g }|j
                  D ]=  }|j                  t        j                  |||j                  |j                               ? t        |      r-|j                  rt        j                  j                  d       |S y)z5Launch a browser, or return a table of URLs to print.T)requiredz@Did not detect your browser. Go to these links to view your app:N)r
   VALUEScoreprojectGetr   appendr   	BrowseAppversionlaunch_browseranyr	   statusPrint)selfargsr    outputsservices        r   Runz
Browse.RunM   s    $$,,00$0?GG==nn'11'2926,,262E2EG H !
 7|			

N	Pnr   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r-    r   r   r   r      s1    
  -(  *r   r   N)r1   
__future__r   r   r   googlecloudsdk.callioper   googlecloudsdk.command_lib.appr   r   googlecloudsdk.corer	   r
   Commandr   r4   r   r   <module>r:      s4      '  ' ( = 0 # *>T\\ >r   