
    $                     .   S r SSKJr  SSKJr  SSKJr  SSKJr  SSKrSSKrSSKrSSK	r	SSK
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rSSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  Sr S\ -   S-   r!Sr" " S S\5      r#g)&Implementation of gsutil help command.    )absolute_import)print_function)division)unicode_literalsN)PIPE)Popen)Command)OLD_ALIAS_MAP)CommandException)HelpProvider)MAX_HELP_NAME_LEN)	constants)
IS_WINDOWS)IsRunningInteractively)GetTermLines)	text_utilz"
  gsutil help [command or topic]
z
<B>SYNOPSIS</B>
a  


<B>DESCRIPTION</B>
  The following command provides a summary of gsutil commands and additional topics on which
  help is available:

    gsutil help

  The following command provides help about the specified command or topic:

    gsutil help [command or topic]

  The following command provides help about the specified sub-command:

    gsutil help [command] [sub-command]

  For example, running the following provides help about the "set" sub-command of the "acl" command:

    gsutil help acl set

  If you set the PAGER environment variable to the path to a pager program
  (such as /bin/less on Linux), long help sections are piped through
  the specified pager.
zUsage: gsutil [-D] [-DD] [-h header]... [-i service_account] [-m] [-o section:flag=value]... [-q] [-u user_project] [command [opts...] args...]c                       \ rS rSrSr\R                  " SSS/\SSSS	S
SS9	r\R                  " SS/SS\
0 S9rS rS rS rSrg)HelpCommandQ   r   help?manr       TF)command_name_aliasesusage_synopsismin_argsmax_argssupported_sub_argsfile_url_okprovider_url_okurls_start_argcommand_helpz"Get help about commands and topics)	help_namehelp_name_aliases	help_typehelp_one_line_summary	help_textsubcommand_help_textc                    U R                  5       u  p/ nU R                  (       d  UR                  S[        -  5        S[	        [
        5      -   S-   n[        US   S S9 H@  nUR                  XER                  R                  UR                  R                  4-  5        MB     UR                  S5        [        US   S	 S9 H@  nUR                  XER                  R                  UR                  R                  4-  5        MB     UR                  S
5        GO SnU R                  S   nXr;  a  UR                  SU-  5        GOX'   nSn[        U R                  5      S:  a  UR                  R                  n	U	(       a:  U R                  S   U	;   a'  US-   U R                  S   -   nXR                  S      n
OSnU	(       d  UR                  SU< SU< S35        Oa/ nU	 H  nUR                  SU< SU< 35        M     UR                  SU R                  S   < SU< SU< SSR                  U5      < 35        U(       d  U(       d,  UR                  R                  nUR                  R                  n
UR                  S5        UR                  SU< SUR                  R                  < S35        UR                  S5        UR                  W
R                  S5      5        [        R                   " US/5      S   nU(       a-  SU< SU< S 3nUR                  S!5        UR                  U5        U R#                  S"R                  U5      5        g)#z)Command entry point for the help command.z%s
Available commands:
z  %-zs%s
r$   c                 .    U R                   R                  $ N	help_specr%   hps    &platform/gsutil/gslib/commands/help.py<lambda>(HelpCommand.RunCommand.<locals>.<lambda>r       R\\-C-C    )keyz
Additional help topics:
additional_helpc                 .    U R                   R                  $ r-   r.   r0   s    r2   r3   r4   w   r5   r6   z6
Use gsutil help <command or topic> for detailed help.Fr   zNo help available for "%s"N    TzThe "zV" command has no subcommands. You can ask for the full help by running:

	gsutil help 
z	gsutil help zSubcommand "z" does not exist for command "zT".
You can either ask for the full help about the command by running:

	gsutil help z9

Or you can ask for help about one of the subcommands:

z<B>NAME</B>
z  z - z

z
  The "zT" alias is deprecated, and will eventually be removed completely.
  Please use the "z" command instead.z


<B>DEPRECATION WARNING</B>
r   )_LoadHelpMapsargsappendtop_level_usage_stringstrr   sortedr/   r%   r(   lenr*   joinr)   stripr   get_OutputHelp)selfhelp_type_maphelp_name_mapoutput
format_str	help_provinvalid_subcommandargr%   subcommand_mapr)   subcommand_examples
subcommand	new_aliasdeprecation_warnings                  r2   
RunCommandHelpCommand.RunCommandj   s   %)%7%7%9"]F99mm/2HHIC 122W<jmN;"CE)j$7$7$A$A$-$7$7$M$M$O O 	PE mm12m,=>"CE)j$7$7$A$A$-$7$7$M$M$O O 	PE mmMN IIaLc		!2S89!&		tyy>A$..CC.		! >c	DIIaL0I&yy|4I!%!mmEH#OP %'! .*#**,/,= > !/ mm
 yy|S#tyy9L/M	OP "!++55I!++55I
--
(
--"I$7$7$M$MO P
--

--	-
.#''dV4Q7) .1)#= MM>?MM-.RWWV_%r6   c                 t   [         (       d  [        5       (       dG  [        R                  " SSU5      n[        R                  " SSU5      n[        R
                  " U5        g[        R                  " SSU5      n[        R                  " SSU5      n[        UR                  S5      5      nS[        R                  ;   a  U[        5       :  a  [        R                  S   R                  S	5      nUS
   R                  S5      (       a  UR                  S5         [        R                  (       a   UR                  [         R"                  5      nOUn[%        U[&        SS9R)                  US9  g[        R
                  " U5        g! [*         a'  n[-        SS	R/                  U5      < SU< 35      eSnAff = f)zOutputs simply formatted string.

This function paginates if the string is too long, PAGER is defined, and
the output is a tty.

Args:
  help_str: String to format.
z<B>r   z</B>Nz[1mz[0;0mr<   PAGERr;   r   lessz-rT)stdinuniversal_newlines)inputzUnable to open pager (z): )r   r   resubr   print_to_fdrC   splitosenvironr   endswithr?   sixPY2encoder   UTF8r	   r   communicateOSErrorr   rD   )rH   help_str	num_linespagerinput_for_pageres         r2   rG   HelpCommand._OutputHelp   sL    z/11r8,hH-hH%vveY1Hvvfk84HHNN4()I"**ln!<jj!'',e	q		6	"	"T	577$OOINN;/$/e4!%	''2{{'I
 H%	  5 # 4 5 	55s   AF 
F7"F22F7c                    [         R                  " [        R                  R                  5       H  u  pn[        SU-  5        M     [         R                  " [        R                  R                  5       H  u  pn[        SU-  5        M     0 n0 n[        R                  R                   H  n/ X5'   M	     [        R                  " [        R                  " 5       [        R                  " 5       5       H  nU[        L a  M  [        R                  R                  Xd5        XdUR                  R                   '   UR                  R"                   H  nXdU'   M	     X6R                  R$                     R'                  U5        M     X44$ )a  Returns tuple of help type and help name.

help type is a dict with key: help type
                         value: list of HelpProviders
help name is a dict with key: help command name or alias
                         value: HelpProvider

Returns:
  (help type, help name)
zgslib.commands.%szgslib.addlhelp.%s)pkgutiliter_modulesgslibcommands__path__
__import__addlhelphelp_providerALL_HELP_TYPES	itertoolschainr   __subclasses__r
   SanityCheckr/   r%   r&   r'   r?   )rH   _module_namerI   rJ   srM   r&   s           r2   r=   HelpCommand._LoadHelpMaps   s@    %11%..2I2IJ${23 K %11%..2I2IJ${23 K MM  //m 0 __\%@%@%B%,%;%;%=?		g	 	%%i?5>I''112(22DD
+4'(  E''11299)D? ))r6    N)__name__
__module____qualname____firstlineno____doc__r
   CreateCommandSpec	_SYNOPSIScommand_specHelpSpec_DETAILED_HELP_TEXTr/   rU   rG   r=   __static_attributes__r   r6   r2   r   r   Q   sn    . **<
, @#)BH#&J$*r6   r   )$r   
__future__r   r   r   r   rz   ra   rq   r]   rd   
subprocessr   r	   gslib.addlhelprs   gslib.commandr
   r   gslib.commandsgslib.exceptionr   gslib.help_providerr   r   gslib.utilsr   gslib.utils.system_utilr   r   r   r   r   r   r@   r   r   r6   r2   <module>r      s    - & %  '  	  	 
    ! '  , , 1 ! . : 0 !	 :Y f*' f*r6   