
    y                         S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJr  SSKJ	r	  S	r
S
rSS jrSrSS jr " S S\R                  5      rg)zIA command that lists all possible gcloud commands, optionally with flags.    )absolute_import)division)unicode_literalsN)base)cli_tree)walker_util_flags__name_c                    ^ U4S jm/ nT" X / 5        U(       d  [         R                  nUR                  SR                  [	        U5      5      S-   5        g)zDisplays the commands in the command tree in sorted order on out.

Args:
  command: dict, The tree (nested dict) of command/group names.
  out: stream, The output stream, sys.stdout if None.
c           	      J  > X![            /-   nU (       a!  U R                  SR                  U5      5        O6U R                  SR                  X1R                  [        / 5      -   5      5        [
        R                  U;   al  U[
        R                      HU  nUR                  [         U5      nUR                  [        / 5      nU R                  SR                  X5/-   U-   5      5        MW     [
        R                  U;   a$  U[
        R                      H  nT" XU5        M     gg)a	  Visit each command and group in the CLI command tree.

Each command line is added to the commands list.

Args:
  commands: [str], The list of command strings.
  command: dict, The tree (nested dict) of command/group names.
  args: [str], The subcommand arg prefix.
 N)_LOOKUP_INTERNAL_NAMEappendjoinget_LOOKUP_INTERNAL_FLAGSr   LOOKUP_COMMANDSLOOKUP_GROUPS)	commandscommandargs	args_nextcnameflagsgWalkCommandTrees	           !lib/surface/meta/list_commands.pyr   4DisplayFlattenedCommandTree.<locals>.WalkCommandTree)   s      5677Ioochhy)* oochh
kk"8"=
=? @7*x//0!uu*A.,b1V!3e!;<= 1 (x--.!Y/ / )    
N)sysstdoutwriter   sorted)r   outr   r   s      @r   DisplayFlattenedCommandTreer'   !   sD    04 ((R(	
**C))DIIfX&'$./r    _SC_c                 `   ^^^ S mUUU4S jmT(       d  [         R                  mT" U / 5        g)aH  Displays the static tab completion data on out.

The static completion data is a shell script containing variable definitons
of the form {_COMPLETIONS_PREFIX}{COMMAND.PATH} for each dotted command path.

Args:
  command: dict, The tree (nested dict) of command/group names.
  out: stream, The output stream, sys.stdout if None.
c                 R    [         SR                  U 5      R                  SS5      -   $ )N__-_)_COMPLETIONS_PREFIXr   replace)paths    r   ConvertPathToIdentifier3DisplayCompletions.<locals>.ConvertPathToIdentifierX   s"    4!8!8c!BBBr    c           	        > U R                  [        5      nX/-   nU R                  [        R                  / 5      nU R                  [        R                  / 5      n/ nXE-    H(  nUR                  UR                  [        U5      5        M*     U(       Ga)  U R                  [        / 5      nU(       a7  TR                  SR                  T
" U5      SR                  Xh-   5      S95        OiTR                  SR                  T
" S/5      SR                  U5      S95        TR                  SR                  T
" U5      SR                  U5      S95        U Hf  nUR                  [        U5      nUR                  [        / 5      nTR                  SR                  T
" X2/-   5      SR                  U5      S95        Mh     U H  n	T" X5        M     g)zVisit each command and group in the CLI command tree.

Args:
  command: dict, The tree (nested dict) of command/group names.
  prefix: [str], The subcommand arg prefix.
z{identifier}=({args})
r   )
identifierr   z-GCLOUD-WIDE-FLAGS-N)
r   r   r   r   r   r   r   r$   formatr   )r   prefixr   r   r   groupsnamesr   r   r   r1   r   r&   s             r   r   +DisplayCompletions.<locals>.WalkCommandTree[   s    ;;,-DF?D{{833R8H[[//4FEll155.23 kk0"5e			+22.t4%-( 3 * 	+ 			+22.0E/FG% 3 " 	# 			+22.t4% 3 " 	# !uu*A.,b1		+22.tf}=% 3 " 	#  a r    N)r"   r#   )r   r&   r1   r   s    `@@r   DisplayCompletionsr:   M   s'    C"H 

**C'2r    c                   4    \ rS rSrSr\S 5       rS rS rSr	g)ListCommands   z2List all possible gcloud commands excluding flags.c                     U R                  SSS[        -   S-   S9  U R                  SSSS9  U R                  SSS	S9  U R                  S
SSS9  U R                  SSSSS9  U R                  SSSSS9  g )Nz--completions
store_truez              Write the static TAB completion data on the standard output. The
              data is a shell script containing variable definitons of the
              form ```z/{COMMAND.PATH}``` for each dotted command path.)actionhelpz--flagsz4Include the non-global flags for each command/group.z--flag-valuesz        Include the non-global flags and flag values/types for each
        command/group. Flags with fixed choice values will be listed as
        --flag=choice1,..., and flags with typed values will be listed
        as --flag=:type:.z--hiddenz#Include hidden commands and groups.z--universe-compatible-commandsTz.Exclusively show universe compatible commands.)hiddenr@   rA   restrictzCOMMAND/GROUP*z^Restrict the listing to these dotted command paths. For example: gcloud.alpha gcloud.beta.test)metavarnargsrA   )add_argumentr.   )parsers    r   ArgsListCommands.Args   s    
 "	"
 @@  	 C  E    2  4 (=	  ?
 ;	  =r    c                 "   UR                   (       a  SUl        SUl        SUl        SUl        [
        R                  " U R                  UR                  UR                  S9R                  UR                  UR                  UR                  5      $ )NTF)
with_flagswith_flag_values)
completionsr   flag_valuesrB   universe_compatible_commandsr   CommandTreeGenerator_cli_power_users_onlyWalkrC   )selfr   s     r   RunListCommands.Run   st    djddk*/d'++""::)) d4;;994==I	Jr    c                 P    UR                   (       a  [        U5      $ [        U5      $ N)rN   r:   r'   )rT   r   results      r   DisplayListCommands.Display   s!    ''&v..r     N)
__name__
__module____qualname____firstlineno____doc__staticmethodrI   rU   rZ   __static_attributes__r\   r    r   r<   r<      s#    :%= %=N
J/r    r<   rX   )ra   
__future__r   r   r   r"   googlecloudsdk.callioper   r   r   r   r   r'   r.   r:   Commandr<   r\   r    r   <module>rg      sR     P &  ' 
 ( , / #   &0R  4n:/4<< :/r    