
                         z    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
  G d d	ej                        Zy
)z:The command to list installed/available gcloud components.    )absolute_import)division)unicode_literals)base)util)logc                   2    e Zd ZdZed        Zd Zd Zd Zy)Lista  List the status of all Google Cloud CLI components.

  This command lists all the available components in the Google Cloud CLI. For
  each component, the command lists the following information:

  * Status on your local workstation: not installed, installed (and
    up to date), and update available (installed, but not up to date)
  * Name of the component (a description)
  * ID of the component (used to refer to the component in other
    [{parent_command}] commands)
  * Size of the component

  ## EXAMPLES
  To list the status of all Google Cloud CLI components, run:

    $ {command}

  To show the currently installed version (if any) and the latest available
  version of each component, run:

    $ {command} --show-versions
  c                 (   t         j                  j                  |        t         j                  j                  |        | j	                  ddd       | j	                  dddd       | j	                  d	dddd
       | j	                  dddd       y )Nz--only-local-state
store_truez'Only show locally installed components.)actionhelpz--show-versionsFz8Show installed and available versions of all components.)requiredr   r   z--show-hiddenT)r   r   r   hiddenz--show-platformz8Show operating system and architecture of all components)r   PAGE_SIZE_FLAGRemoveFromParserURI_FLAGadd_argument)parsers    lib/surface/components/list.pyArgsz	List.Args3   s    ((0MM""6*
6  
 E,G  I %G  
 G	  I    c                    ddg}|j                   rg ndg}|j                  d       |j                  r|j                  ddg       |j                  ddg       |j                  r|j                  d	d
g       |j                         j                  dj                  dj                  |      dj                  |                   y )Nboxztitle="Components"zstate.name:label=Statuszname:label=Namez2current_version_string:label=Installed:align=rightz.latest_version_string:label=Latest:align=rightzid:label=IDz5size.size(zero="",min=1048576):label=Size:align=rightz+platform.architecture.id:label=ARCHITECTUREz3platform.operating_system.id:label=OPERATING_SYSTEMztable[{attributes}]({columns}),)
attributescolumns)	only_local_stateappendshow_versionsextendshow_platformGetDisplayInfo	AddFormatformatjoin)selfargsr   r   s       r   
_SetFormatzList._SetFormatJ   s    
J ))b0I/JGNN$%nn
>
:  NN?
  nn
7
?  	##$D$K$K88J''1B %L %D Er   c                     | j                  |       t        j                  |      }|j                  |j                  |j
                        }|\  }| _        | _        |S )zRuns the list command.)show_hiddenr   )r)   r   GetUpdateManagerr
   r+   r   _current_version_latest_version)r'   r(   update_managerresultto_prints        r   RunzList.Runb   s\    OOD**40N  T-=-=262G2G ! IF>D;Xt$d&:Or   c                    |st         j                  j                  d       | j                  dndj	                  | j                        }t         j                  j                  dj	                  | j
                  |             y )Nz
No updates. z [{}]a   To install or remove components at your current Google Cloud CLI version [{current}], run:
  $ gcloud components install COMPONENT_ID
  $ gcloud components remove COMPONENT_ID

To update your Google Cloud CLI installation to the latest version{latest}, run:
  $ gcloud components update

)currentlatest)r   statuswriter.   r%   r-   )r'   resources_were_displayedlatest_version_strings      r   EpilogzList.Epilogk   sk    #	jj'#'#7#7#?R")..1E1E"F JJ  F4((1FFGIr   N)	__name__
__module____qualname____doc__staticmethodr   r)   r2   r;    r   r   r
   r
      s.    . I I,E0Ir   r
   N)r?   
__future__r   r   r   googlecloudsdk.callioper   %googlecloudsdk.command_lib.componentsr   googlecloudsdk.corer   ListCommandr
   rA   r   r   <module>rG      s3     A &  ' ( 6 #]I4 ]Ir   